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.
1 2 3 4 5 6 7 8 9 10 | /** * 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:
$scripts
->add(
'jquery'
, false,
array
(
'jquery-core'
),
'1.12.4'
);
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.