Created
August 11, 2017 14:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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