JQ Migrate is Installed: How to Remove

2 min


I recently logged into my google search console when I received the message JQ Migrate is installed. It looks something like this.

I searched online and finally came up with a conclusive answer.

JQ Migrate or jQuery Migrate is a drop-in JavaScript library, that allows developers to preserve the backwards compatibility of their jQuery code.

After the update of jQuery 1.9, new lines of code were implemented, but unfortunately, some plugins on WordPress, still depended on these, outdated jQuery 1.9 and earlier version.

So WordPress developers came up with jQuery migrate, to prevent sites from breaking, who were still using outdated plugins, which depended on, jQuery 1.9 or later.

How to Remove jQuery Migrate?

There are two ways to remove jQuery migrate:

Option 1: Add Code to Functions.php of your Theme

The first method to remove jQuery Migrate is quite simple. Login to your WordPress dashboard. Go to appearance, then theme editor. Select your functions.php file. Add the following line of code provided below. Save the file.

Login to your WordPress dashboard.

Go to appearance

Then theme editor.

Click and open functions.php file.

Add the following line of code to the end of the functions.php

//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');

Save and Update File

Option 2: Install and Activate Remove jQuery Migrate Safely Plugin

The second way you can remove jQuery Migrate, is to install and activate Remove jQuery Migrate Safely WordPress plugin.

This option although easier, can add database table to your website. But if you are not conversant with editing your functions.php folder, then this option, is the safer bet. Although, the plugin has not been updated in 3 years.

Make sure you backup your website, before you proceed.

Should You Remove jQuery Migrate?

The main benefit of removing jQuery migrate is that you reduce the unnecessary load time on your website, caused by the jQuery script propagating.

If you are sure, your website, doesn’t have outdated files or plugins, then you can go ahead and deactivate jQuery Migrate, but make sure you backup your entire website, before going ahead, so that you can easily restore your site, if anything breaks.


0 Comments