WordPress loads jquery-migrate.js in order to support older jQuery functions that some themes and WordPress plugins still use. However, many sites do not need jQuery Migrate, at all.
The following code snippet will remove jquery-migrate.js from your site.
Don’t do this unless you are absolutely sure that you understand the implications.
If you’re using old plugins or an old theme that use old jQuery functions, then removing jQuery Migrate may break those 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
(“dequeue” means to stop it from loading on your site).
If you’re not sure whether your theme or plugins need jquery-migrate.js, then you can try this. Remove jquery-migrate.js temporarily, and go through your site and test all of your plugins’ features to see if everything still works. If anything on your site breaks, then simply remove this snippet and everything will return to normal. This snippet makes no permanent changes, nor does it alter anything in your WordPress database. If you’re using an updated theme and plugins, everything should work just fine without jQuery Migrate. Good luck.
jQuery Migrate is loaded as a bundle with ‘jquery-core’ in WordPress. So the following code snippet removes the bundle, thereby removing jquery-migrate.js, 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' );
Ana
January 5th, 2017 at 8:04 am
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 🙂
Isabel
January 6th, 2017 at 2:58 pm
You’re welcome. To remove jquery.js altogether, remove line 7 from the code above, which is this line:
Hope that helps.
Ana
January 9th, 2017 at 2:29 am
Wow! Thank you very much!
It worked!
Have a great day 🙂
Samuel Torres
April 3rd, 2017 at 10:21 am
Hi Isabell:
Where i’am going to put this snipet code?
Thanks in advance
Have a Great day
Isabel
April 3rd, 2017 at 3:29 pm
Hi. See How To Add Code. Hope that helps.
Yasir
November 11th, 2017 at 5:01 am
In the theme’s functions.php file.
It’s inside the parent folder of your theme directory.