Skip to content

Instantly share code, notes, and snippets.

@MikelArnaiz
Created August 11, 2017 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikelArnaiz/e889f58f7eef040af043a6266ac79460 to your computer and use it in GitHub Desktop.
Save MikelArnaiz/e889f58f7eef040af043a6266ac79460 to your computer and use it in GitHub Desktop.
How to add jQuery from CDN in Wordpress or how to disable jQuery
function disable_jQuery() {
if(!is_admin()){
wp_deregister_script('jquery');
}
}
function add_jQuery_from_cdn(){
if(!is_admin()){
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://code.jquery.com/jquery-2.2.4.min.js', null, null, true);
wp_enqueue_script('jquery');
}
}
// Disable jQuery
add_action('wp_enqueue_scripts', 'disable_jQuery');
// Replace local jQuery with CDN version
add_action('wp_enqueue_scripts', 'add_jQuery_from_cdn');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment