Load jQuery library from Google CDN

Load jQuery library from Google CDN

WordPress itself uses the jquery in all wordpress themes and loads automatically. But it is always good to load the jquery library through google CDN. It saves your sites bandwidth. Many people already written about same so here I am just putting the method.

Load jQuery library from Google CDN

Load the jQuery library from Google CDN is always good for seo and better performance of site. WordPress itself uses the jquery in all wordpress themes and loads automatically.

For more libraries you can visit the following URL:
https://developers.google.com/speed/libraries/devguide

What you need is, just copy and paste the following code into your functions.php file.

function jquery_from_google_cdn() {
   if (!is_admin()) {
      wp_deregister_script('jquery');
      wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', false, '1.11.1');
      wp_enqueue_script('jquery');
   }
}
add_action('init', 'jquery_from_google_cdn');
Load jQuery library from Google CDN
Load jQuery library from Google CDN

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.