DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

By default, WordPress load its own copy of jQuery in your theme. But what about loading the library from Google CDN? Here’s an easy way to do it.

Paste the code below into your functions.php file:

function jquery_cdn() {
   if (!is_admin()) {
      wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', false, '1.8.3');
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!



  1. I recommend making the last argument null to ensure it doesn’t stick the version in the querystring (thus breaking caching if this version has been downloaded elsewhere). Also, latest jQuery is 1.10.2.

  2. Why is misinformation like this still being spread around the web.

    1. Use the jQuery that comes with WordPress period end of story
    2. Use the right hook, wp_enqueue_scripts
    3. Know that if you do this you’re going to break stuff. (FYI current WordPress jQuery version: 10.1)

  3. Christian Oliff

    There’s a good WordPress plugin which handles this which I recommend – search for ‘Use Google Libraries’ in the official WordPress plugins directory.

    Also, your code snippet references an old version of jquery. The version shipping with WordPress 3.6 is 1.10.2.

  4. This is almost sure to cause warnings if you have WP_DEBUG on. The reason being that wp_register_script should only be called on the wp_enqueue_scripts action hook.

  5. If google CDN isn’t available (maybe),how can I to do? Using the CDN first, and if it fails, load the local copy,that I think it’s the best option.

  6. I guess it’s time to finally remove this site from my RSS feed…

  7. Christopher Anderton

    To add on Chris Olbekson list:

    4. Google are blocked in some countries.

Leave a Comment

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