How to Remove jQuery Migrate in WordPress

Starting with WordPress 5.7, WordPress disabled the jQuery Migrate file, but you can still see that some websites are running it. Even when I was optimizing my website to make it load faster, I discovered that jquery-migrate.min.js was being loaded by one of the plugins I was using to display the table of contents on my website.

Upon closer inspection, I discovered that the plugin relied on functionality from the old JQuery version. Instead of upgrading the plugin, the plugin developer included the jQuery Migrate file. Most people don’t think that it’s a big deal, but if you want to optimize your website, then reducing a single HTTP request can drastically improve the performance of your website.

showing jquery-migrate.min.js file loading on wptalky
jquery-migrate.min.js

So if your website is also among those websites which still had the jquery-migrate.min.js file, then you should know how to remove jQuery Migrate in WordPress, and on top of that, you should also need to know why it is still there in your website.

In this article, I will guide you step-by-step through removing jQuery Migrate from WordPress completely, but before removing it, it’s important for you to know why jQuery Migrate is used in your website. So let’s get started.

What is jQuery Migrate & Why is it Still Included in WordPress?

The jQuery Migrate is a Javascript file that helps WordPress users to upgrade their website from jQuery 1.9 or older versions to the new jQuery 3.x version without breaking the functions which are using the older jQuery module.

WordPress moved to the latest version of jQuery in 2013, and to maintain the integrity of themes and plugins using jQuery version 1.9 or older, it included the jQuery Migrate file. But as of March 2021, WordPress 5.7 makes jQuery Migrate optional, removing it from the installation by default.

However, there are many themes and plugins that are still not updated to jQuery 3.x and load the jquery-migrate.min.js file for themselves. Therefore, if you also see jQuery Migrate on your site, then there must be some plugin or theme which may be using it.

✍️ Author’s Note

Many page builders like Divi, Elementor, Thrive Architect, and Visual Composer still uses jQuery Migrate to maintain their functionality because they are too lazy to upgrade to the latest jQuery version. So if you’re also using any page builder, then you shouldn’t remove jQuery Migrate from your website.

How To Remove jQuery Migrate In WordPress

There are three ways to remove jQuery Migrate: by removing the theme and plugin that is using the jquery-migrate.min.js file, removing it using a plugin, or adding a couple of lines of code to your functions.php file.

1. Changing the Theme/ Plugin

I would recommend that you should remove the plugin or theme that is causing the jQuery Migrate file to load. As WordPress upgrades, so do all the plugins and themes it uses. It’s not appropriate to continue using a plugin/theme if it can’t even upgrade to the latest standard imposed by WordPress.

But for some reason, if you’re not comfortable changing the theme or plugin that is causing the jQuery Migrate to load, then you can use a cache plugin to remove it explicitly and check if any functionality has been broken. If it’s not, then you can continue using that theme or plugin without jQuery Migrate.

2. Using an Optimization Plugin

The majority of optimization plugins (such as Perfmatters or WP Rocket) have options to remove jQuery Migrate and other unnecessary files from your website. In case you’re using an optimization plugin, then you can use it to remove jQuery Migrate.

In case you are not using any optimization plugin, then I would not recommend installing any plugin to remove jQuery Migrate. In this case, I recommend manually removing it with the code provided in the next step.

3. Using Code Snippets (or functions.php)

To remove jQuery Migrate from your website, open the functions.php file and add the following code there at the end of the file. If you are using a plugin like “Code Snippets“, you can use it instead of editing your functions.php file.

This code will prevent jQuery Migrate from loading on the front end but will load it in the admin panel in order to prevent anything from breaking at the admin end.

Should You Remove jQuery Migrate?

Yes, you should remove jQuery Migrate from your website if you’re not using it. Because it is no longer used by WordPress, removal of it will not harm your website in any way. Still, if a plugin or theme is really using it, then it might break some functionality.

As I mentioned earlier, jQuery Migrate was removed in WordPress 5.7, which rolled out in March 2021, and even after such a long time, if any plugin or theme is using it, I don’t think they will ever upgrade. So, it’s better to remove that plugin or theme instead of keeping jQuery Migrate on your website.

What to do after removing jQuery Migrate?

Once you have removed the jquery-migrate.min.js file from WordPress, it’s important that you check for any errors on the front end side of your website.

There are two ways for debugging in WordPress, one is manually by checking all the functionality of all the plugins & themes installed on your website, which includes menus, table of contents, social share buttons, share counters, forms, visible changes, or any other functionality present in your website.

Alternatively, if you have a bit of technical knowledge, instead of debugging manually, you can also add the code given below in wp-config.php and then check for errors in the console log using inspect elements developer tools. This code shows all the errors which are present on your WordPress website.

define('SCRIPT_DEBUG', true);

If you see some errors which are caused due to disabling the jQuery Migrate file, then you have to revert back and keep the file, or you can also remove the plugin or theme that is using the jquery-migrate.min.js file and look for similar alternatives.

Also, don’t forget to remove the code from the wp-config.php file once the debugging is completed.

Wrapping Up!

I hope that this guide helped you in disabling jQuery Migrate from your WordPress blog. Keeping your blog optimized is critical, otherwise, it may hurt the organic ranking of your blog.

With this guide, you’re one step closer to optimizing your blog. Apart from removing jQuery Migrate, there are several other JavaScript and CSS files that can be removed to speed up your blog. This includes disabling the WordPress emoji javascript file, removing the Gutenberg CSS file (if you’re not using the block editor), lazy loading images, delaying javascript files that are not essential at first, and combining & minifying CSS & JS files.

You can learn about all of them by regularly checking our blog for new articles. If you have any questions regarding the current article or need any other help with WordPress, comment down below.

Leave a Comment