How to Remove the jQuery Migrate Script from WordPress
If your WordPress project uses jQuery, then by default, WordPress also loads the jQuery Migrate script along with it. In 99% of cases, you don’t actually need this script. jQuery Migrate restores support for outdated features that have already been removed from the main jQuery library.
You can determine whether jQuery Migrate is loaded by checking for a message in your browser’s console

or by inspecting the HTML code of your website.

In most cases, the jQuery Migrate script doesn’t do anything useful and only adds extra load to your website, increasing the page loading time. This negatively affects user experience and can also harm your SEO. You can read more about how loading speed affects SEO in our related article — “Why Website Loading Speed Matters for SEO”.
There are several ways to disable the jQuery Migrate script. Personally, I prefer the method that doesn’t require any third-party plugins — simply by adding a small piece of code to your theme’s functions.php file.
PHP
// functions.php
/**
* delete jquery-migrate
*/
add_action('wp_default_scripts', function( $scripts ) {
if ( ! empty( $scripts->registered['jquery'] ) ) {
$scripts->registered['jquery']->deps = array_diff(
$scripts->registered['jquery']->deps,
['jquery-migrate']
);
}
});
The WordPress CMS is a great tool, but WordPress itself and its plugins often include unnecessary scripts and styles, thereby slowing down the site’s loading time. This, in turn, negatively impacts SEO. Therefore, you need to be careful about what and how you include. And in cases like jQuery Migrate, optimization is essential.
Similar posts:
-
Step Options Plugin for WordPress
At some point, I needed a way to display identical content blocks across multiple pages, with the ability to manage and update them easily from the WordPress admin panel....
-
Caching Data to a File Using PHP
Sometimes it becomes necessary to limit the number of requests to an external data source, especially when the data does not change frequently. For example, this can be u...
-
How to Upload Files to a Server Using PHP
Uploading files to a website is a common task. Consider uploading files to a PHP server using the POST method. This will require a form with the "file" field type and an ...
Excellent web site. Lots of helpful info here. I am sending it to a few friends ans additionally sharing in delicious. And certainly, thank you for your sweat!