How to load jQuery from Google CDN

Paste the code below into your functions.php file:

function jquery_cdn() {
   if (!is_admin()) {
      wp_deregister_script('jquery');
      wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3');
      wp_enqueue_script('jquery');
   }
}
add_action('init', 'jquery_cdn');

Once you saved the file, WordPress will load jQuery from Google CDN.

Thanks to WP Tips.ru for the recipe!

Leave a Reply

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