Adding jQuery from Google CDN

To add WordPress jQuery from Google Server in your website add this below code in functions.php file:

if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js", false, null, TRUE);
wp_enqueue_script('jquery');
}

OR

Simply copy and paste this below code in your theme footer.php file before the html body tag:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

To check all available libraries hosted by Google visit this below link

https://developers.google.com/speed/libraries/devguide#jquery

Important: Never deregister WordPress jQuery completely from your website. You should add WordPress jQuery from google server if it is not wordpress admin section.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
3 + 1 =