jQuery 4 Migrate
Starting with Drupal 11, Drupal core bundles jQuery 4 instead of jQuery 3. jQuery 4 removed several old functions - like jQuery.isFunction() and jQuery.type() - that had been marked "deprecated" for years but were still present and working right up until this version. A lot of older third-party JavaScript plugins (carousels, lightboxes, countdown timers, and similar widgets) still call these removed functions, so as soon as a site upgrades to Drupal 11, those plugins throw JavaScript errors and stop working - with no warning during the upgrade itself.
This module solves that by providing jQuery Migrate, a small compatibility script maintained by the jQuery Foundation. It adds the removed functions back as thin wrapper functions, so the old plugin code keeps working exactly as it did before, without you having to find, patch, or replace the plugin yourself.
Features
- Packages jQuery Migrate 4.x as a standard Drupal library (
jquery_4_migrate/jquery-migrate), so any custom or contributed library can declare it as a dependency, the normal Drupal way. - Optional sitewide toggle: rather than editing every broken library's
.libraries.ymlto add the dependency by hand, a single setting loads jQuery Migrate automatically wherever core jQuery loads. - The sitewide setting is gated behind its own permission, so only trusted roles can turn on a behavior that affects every page.
- Acts as an immediate, non-invasive fix for plugins broken by the jQuery 3-to-4 transition, buying time to update or replace them properly later, without touching their code.
Post-Installation
- Enable the module.
- This module does not bundle the jQuery Migrate library file directly, per Drupal.org's policy against including third-party libraries in module repositories. Download the built file and place it in your Drupal installation's
/librariesdirectory, atlibraries/jquery-migrate/jquery-migrate.min.js. - Go to Configuration > System > jQuery 4 Migrate Settings
(/admin/config/system/jquery-4-migrate-settings). This requires the "Administer jQuery 4 Migrate" permission. - Check "Enable jQuery 4 Migrate" to load it sitewide, or leave it unchecked and instead add
jquery_4_migrate/jquery-migrateas a dependency to just the specific library that needs it.
Additional Requirements
- No other contributed modules are required.
- Requires manually placing the jQuery Migrate 4.x library file at
/libraries/jquery-migrate/(see Post-Installation above). - Only relevant on Drupal core ^11, where jQuery 4 is bundled. It has no effect on earlier core versions running jQuery 3.x.
Recommended modules/libraries
None required. If you're trying to identify exactly which legacy plugin needs this, jQuery Migrate itself logs a console warning every time it patches a call to a removed API - your browser's JavaScript console is the fastest way to find the source.
Similar projects
The existing jQuery Migrate project bundles jQuery Migrate 3.x, which targets the jQuery 1.x/2.x-to-3.x transition. It's explicitly gated to only load when jQuery is >= 3.0 and < 4.0, so it does not help on Drupal 11's jQuery 4 - this module covers that gap specifically.
Community Documentation
- jQuery Migrate official project
- Drupal core issue #3534576 - background on why this isn't handled in core directly, and the core maintainers' invitation for a contributed solution like this one.
This module deliberately trades a small amount of overhead (one more small script on every page that loads jQuery) for not having to hunt down and patch every legacy plugin individually. It's meant as a practical stopgap, not a permanent fix - if you rely on it for a specific plugin, that plugin is worth updating or replacing when you get the chance, since jQuery Migrate itself won't cover APIs removed in some future jQuery 5.