Performance PHP Beginner

Remove jQuery Migrate on the Frontend

Dequeue the jQuery Migrate script on the frontend for sites whose themes and plugins are compatible with modern jQuery, removing an unnecessary dependency.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 9 lines
add_action( 'wp_default_scripts', function( $scripts ) {
    if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
        $jquery_deps = $scripts->registered['jquery']->deps;
        $scripts->registered['jquery']->deps = array_diff(
            $jquery_deps,
            [ 'jquery-migrate' ]
        );
    }
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

WordPress bundles jQuery Migrate alongside jQuery itself. jQuery Migrate is a compatibility shim that restores deprecated jQuery APIs removed in jQuery 3.x, allowing older plugins and themes written for jQuery 1.x to continue working without updates. On sites running modern, well-maintained themes and plugins, jQuery Migrate provides no value, it’s a ~9KB script that every visitor downloads and executes for no practical benefit.

What the code does

This approach removes the dependency at the script registration level rather than dequeuing the script after the fact, which is more reliable.

How WordPress Loads jQuery

WordPress registers jQuery as a bundle that depends on jquery-migrate. When anything enqueues jquery, WordPress automatically loads both jquery-core and jquery-migrate as its dependencies. The snippet removes jquery-migrate from jQuery’s dependency list, so enqueuing jQuery loads only the core library going forward.

Testing Before Committing

Before applying this permanently, test your site thoroughly, check the browser console for JavaScript errors on every major page type: homepage, blog, product pages, cart, checkout, and any page with interactive elements. jQuery Migrate outputs console warnings when deprecated methods are called; if you’ve already seen those warnings and addressed them (or never seen them), removing Migrate is safe. If you see new errors after removal, a plugin or theme is still using deprecated jQuery APIs and needs updating before Migrate can be removed.

Admin Is Excluded

The ! is_admin() check ensures jQuery Migrate remains available in the WordPress admin. The admin interface and some plugins depend on it in the backend context. Removing it from the admin can break the block editor, meta boxes, and various admin UI components. The performance benefit on the frontend is the target, admin is deliberately left untouched.

Long-Term Outlook

WordPress has been on a multi-year path to drop jQuery Migrate from the default frontend bundle. Each major WordPress release has encouraged plugin and theme developers to remove their jQuery 1.x dependencies. If your plugins are regularly updated and your theme is modern, the ecosystem around your site is likely already Migrate-free in practice, this snippet just makes it official.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only