I think in my long winded website optimization thread in the docs > tutorials > best of forums … I described how to unhook the builtin jquery function and then load that from Google … it’s someplace in here if you don’t want to Google how to do that:
https://forum.tagdiv.com/topic/tutorial-chriss-custom-optimizations-for-functions-php-etc/
thank you!
I read the whole thread. You have done a great job and I hope your health is doing well.
I found this code on your post from august 17, 2016,
/** CUSTOM OPTIM CODE : by Christopher Simmons – REV 8.17.16 */ // Remove jQuery Migrate Script from header and Load jQuery from Google API function simmonsbunny_remove_jquery_migrate_load_google_hosted_jquery() { if (!is_admin()) { wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js’, false, null); wp_enqueue_script(‘jquery’); } } add_action(‘init’, ‘simmonsbunny_remove_jquery_migrate_load_google_hosted_jquery’);
please confirm:
1. is that the whole code to add at the end of functions.php?
2. should I change version?
thanks a lot
Yes… you should change the version. I think my later post at end of the thread, or maybe in my other security [tutorial] there was a bit about testing your post page with Chrome ‘audit’ to double check the jquery version.
Apparently any version of jquery prior to 3x has an XSS vulnerability related to ajax and unsanitized loading of things … so, presumably, one should consider using
so….
https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
Google hosted libs
https://developers.google.com/speed/libraries/
Info on versions of jquery with issues
https://www.cvedetails.com/vulnerability-list/vendor_id-6538/Jquery.html
interesting read on the topic of Javascript in general:
https://www.zdnet.com/article/an-insecure-mess-how-flawed-javascript-is-turning-web-into-a-hackers-playground/
Yes, you can put at end of functions file, or make a custom plugin. Note that if your server is running http/2 it might actually work better to load locally since it will be ‘bundled’ together via https … but you’d need to speed test that. (Sometimes CDN is *not* faster, depending on locale and audience.)