What is Migrate.js – Why and How to Remove jQuery Migrate from WordPress

jQuery Migrate is a javascript library that allows you to preserve the compatibility of your jQuery code developed for versions of jQuery older than 1.9. It basically restores deprecated features and behaviours so that older code will still run properly on the current jQuery version and later. Starting with WordPress 3.6, jQuery Migrate is automatically included on all pages.

Most websites that use up-to-date themes and plugins don’t require jQuery Migrate on the frontend, and thus the script can be safely removed. By removing it, the browser will have one less JavaScript file to download and execute. As a result, your site will load faster!

If you keep your jQuery code up-to-date and are sure that none of your plugins is incompatible with jQuery 1.9 or jQuery 1.10.2 (the new default version in WordPress 3.6), you can just remove the script from on the front-end.

Most up-to-date frontend code and plugins don’t require jquery-migrate.min.js. More often than not, keeping this simply adds unnecessary load to your site. You can see this running if you launch Chrome Devtools console.

Three reasons why it’s a good idea to remove jquery migrate

  • There is no reason to waste an extra HTTP call to serve an extra JS file.
  • It’s better to keep your code, themes and plugins updated than it is to patch in support with an extra file.
  • If you are running plugins that use older jQuery code, it’s probably better to update them or switch to an alternative that is kept updated.

How to remove jQuery migrate from WordPress?

Removing jQuery migrate from WordPress is quite easy. You just need to add following lines of code to your theme’s function.php file.

//Remove JQuery migrate
function remove_jquery_migrate($scripts)
{
    if (!is_admin() && isset($scripts->registered['jquery'])) {
        $script = $scripts->registered['jquery'];
        
        if ($script->deps) { // Check whether the script has any dependencies
            $script->deps = array_diff($script->deps, array(
                'jquery-migrate'
            ));
        }
    }
}

add_action('wp_default_scripts', 'remove_jquery_migrate');

Another easy way to disable it by using the plugin named Remove jQuery Migrate Safely. If you are unsure if your website still requires jQuery Migrate, you can add the following line to your wp-config.php and watch the console as you browse your site for any logs.

define('SCRIPT_DEBUG', true);

As I mentioned above, jQuery migrate adds unnecessary load to your site. Thus, I recommend removing it from your website or blog. Is this article helpful? Let me know in the comment section below.

What is Migrate.js – Why and How to Remove jQuery Migrate from WordPress
Rate this post

Join over 20,000 users and get our best content

Each week we send 1 email to 20,000 smart entrepreneurs just like you. Enter your email below to join the crew.

Thank you for subscribing.

Something went wrong.