Web & Software Developer

Remove jquery-migrate.js in WordPress

Don’t do this unless you are absolutely sure that you understand the implications. WordPress loads jquery-migrate.js in order to support older jQuery functions that many themes and WordPress plugins still use. So, removing jQuery Migrate may break some plugins and themes. If you’re sure that your themes and plugins do not require any deprecated jQuery functions, then you can use the following snippet to dequeue jquery-migrate.js. jQuery migrate is loaded as a bundle with ‘jquery-core’. So this removes the bundle, then re-loads ‘jquery-core’ by itself.

/**
* Dequeue jQuery migrate script in WordPress.
*/
function isa_remove_jquery_migrate( &$scripts) {
	if(!is_admin()) {
		$scripts->remove( 'jquery');
		$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4' );
	}
}
add_filter( 'wp_default_scripts', 'isa_remove_jquery_migrate' );

By

We've 3 Responses

  1. Thank you!!
    Now I’m trying to do the same thing for jquery.js
    Could you help to remove it too?

    Thank you very much 🙂

    January 5th, 2017 at 8:04 am

    • You’re welcome. To remove jquery.js altogether, remove line 7 from the code above, which is this line:

      $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4' );

      Hope that helps.

      January 6th, 2017 at 2:58 pm

  2. Wow! Thank you very much!
    It worked!
    Have a great day 🙂

    January 9th, 2017 at 2:29 am

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]