How to remove jQuery Migrate from WordPress site?

How to remove jQuery Migrate from WordPress site?

In the process of optimizing the site, the developer can try to reduce the number and size of scripts loaded on the site. One of these scripts can be jquery-migrate.js.

jQuery Migrate is a plugin for the jQuery JavaScript library that helps developers update their code from older versions of jQuery to newer versions. It provides a way for developers to identify and fix compatibility issues that may arise when updating their code to newer versions of jQuery.

As newer versions of jQuery are released, some features and behaviors may change or be deprecated. This means that code that worked in older versions of jQuery may no longer work as expected in newer versions. jQuery Migrate provides a bridge between older versions of jQuery and newer versions, allowing developers to continue using their existing code while updating to newer versions of jQuery.

jQuery Migrate also includes warnings and messages in the browser console to help developers identify potential issues in their code, and it provides information on how to update their code to ensure compatibility with newer versions of jQuery.

For disable loading jQuery Migrate script (jquery-migrate.js or jquery-migrate.min.js) on your WordPress site you can use "wp_default_scripts" filter:

add_filter( 'wp_default_scripts', function($scripts) {
    if(!is_admin()) {
        $scripts->remove( 'jquery');
        $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4' );
    }
}, PHP_INT_MAX );

Put this code to your theme`s function.php. If jQuery Migrate succesfully deleted - check your site functionality. if everything is working properly - get profit !

Read more