Reputation: 115
I run WordPress version 4.7.2. and it uses jQuery version 1.12. I need to update this version to a higher one,
i can use :
function sof_load_scripts() {
if ( !is_admin() ) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://ajax.googleapis.com /ajax/libs/jquery/1.8.2/jquery.min.js', '1.8.2', false);
wp_enqueue_script('jquery');
}
}
add_action( 'wp_enqueue_scripts', 'sof_load_scripts' );
but in the themeforest developers quide we have :
The default version of jQuery being used must never be deregistered. JavaScript and CSS files should never be loaded directly. Plugins should not attempt to load duplicate or alternate versions of files already included in WordPress Core, especially jQuery.
how can i update version of jquery ?
Upvotes: 2
Views: 1721
Reputation: 15979
Your function is actually ok if you really want to change the version sitewide.
Just another remark - note that you can use also 2 ( or more ) different versions together thanks to the jQuery noConflict
mode and that way you could use the version you need on your specific plugin / theme and leave the defaults for the rest.
See more details here : Can I use multiple versions of jQuery on the same page?
Upvotes: 2