A ticket created by Aaron Jorbin four years ago to move WordPress to the latest 3.x branch of jQuery is finally coming to fruition. However, the WordPress development team will need to make this transition in stages, particularly after waiting for so long.
WordPress has fallen behind on keeping jQuery updated. For a platform that routinely suggests that users need to be running the latest and greatest version, it is odd that WordPress itself has not done the same with third-party code that it relies on. WordPress currently bundles jQuery version 1.12.4, a version of the library released in 2016. It is also a version that supports Internet Explorer 6, 7, and 8.
Far too many themes and plugins rely on this dated version of jQuery to move any faster. While plugins could choose to overwrite core WordPress’s bundled version of jQuery with the latest version, themes have had no such option. The official theme directory guidelines require themes to utilize the core-bundled scripts, including jQuery. There is a good reason for this: for the most part, it ensures compatibility with core and third-party plugins.
However, now it is time to move on.
WordPress has a three-stage plan to bring jQuery up to date. The core team asks that theme and plugin developers begin testing their extensions with the Test jQuery Updates plugin. This will help them bring code up to date throughout this transitional period.
The first step in this process will be removing the jQuery Migrate 1.4.1 script from WordPress 5.5, which was released earlier today. This version of jQuery Migrate makes older code compatible and helps developers migrate to jQuery 1.9+.
This move will undoubtedly break some plugins and themes. The core team has made the Enable jQuery Migrate Helper plugin available for end-users. “It is intended to be run in production on sites that experience jQuery-related problems after updating to 5.5,” said Ozz. “It works by re-enabling jQuery Migrate and by showing the warnings about the use of outdated/deprecated jQuery functions to site admins.”
The long-term goal is to get developers to update their extensions. In the meantime, this plugin should ease some of the problems.
Ozz said the biggest thing developers need to do right now is to make sure they are testing their extensions against WordPress 5.5. “Ideally, paying more attention to any old jQuery-based scripts and confirming they still work as expected,” he continued. “In almost all cases, the fixes are trivial.”
Beyond WordPress 5.5, things will start to take shape. The tentative plan is to update to the latest version of jQuery and add the latest version of jQuery Migrate as part of the WordPress 5.6 release.
“Again, Migrate will be used to help in updating jQuery based scripts, and also as a backward-compatibility ‘fix’ while plugins and themes get updated,” said Ozz. “The version of Migrate in WordPress 5.6 will be different, as it will correspond to the latest jQuery version. It will serve the same purpose as when it was added for the first time, but now will help core, plugins, and themes get updated from jQuery 1.12.4 to 3.5.1 (or later).”
The third leg of the process will be to once again remove jQuery Migrate from WordPress. This change is tentatively planned for WordPress 5.7, which will not be released until 2021. The end goal is to remove the reliance on Migrate and ship the latest version of jQuery until someday — perhaps far into the future — there may no longer be a need for bundling it with WordPress at all.
“Following the best practices and the recommendations of the jQuery team, Migrate should be used as a helper tool, not as a permanent backward-compatibility solution,” said Ozz. “Ideally, WordPress will be able to do this.”