Load jQuery with Google Libraries API

Sam Deering

google load jquery

Usually if you want to use jQuery you need to download the latest package, save the .js file in your js/ folder and then include the link in your page header. This can become time consuming especially when you need to test different versions of jQuery for compatibility with plugins or code you are developing. It also is annoying to keep upgrading to the latest version each time they release a new version (usually every few months or so). Here comes Google to the rescue (once again!) by offering a Library API which can load the latest version (or any version) of pretty much any JavaScript Library going. This saves you downloading them onto your own host each time you use a library. Dynamically Load jQuery Library Using Plain JavaScript.

The Libraries API provides your applications with stable, reliable, high-speed, globally available access to all of the most popular, open-source JavaScript libraries. Your application can use our very flexible loader google.load() or direct, path-based access to the scripts.

Using Google API to Dynamically Load jQuery

Step 1 Get your Google API key

Step 2 Put this code in your header:

<script type="text/javascript" 

Step 3 Put this code in your header:

<script type="text/javascript">google.load("jquery", "1.6.1");></script>

Or you can use a direct link:

No Strings attached Include, Latest Versions

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>

See how to fall back to your own local jQuery package if the Google one doesn’t load (not likely).

Tip: You can use google.load(“jquery”, “1”);  to automatically load the latest version of jQuery.

The jQuery package details

name: jquery
latest version: 1.6.1 (view older versions)1.2.3, 1.2.6, 1.3.0, 1.3.1, 1.3.2, 1.4.0, 1.4.1, 1.4.2
load request: google.load(“jquery”, “1.6.1”);
extras: uncompressed:true (as in google.load(“jquery”, “1.6.1”, {uncompressed:true});
path: https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js
path(u): https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js
site: http://jquery.com/
note: 1.2.5 and 1.2.4 are not hosted due to their short and unstable lives in the wild…

Other supported Libraries in the Google API

  google.load("chrome-frame", "1.0.2"); 
  google.load("dojo", "1.5"); 
  google.load("ext-core", "3.1.0"); 
  google.load("jquery", "1.6.1"); 
  google.load("jqueryui", "1.8.6"); 
  google.load("mootools", "1.3.0"); 
  google.load("prototype", ""); 
  google.load("scriptaculous", "1.8.3"); 
  google.load("swfobject", "2.2"); 
  google.load("yui", "2.8.2"); 
  google.load("webfont", "1.0.15");
Source: http://code.google.com/apis/libraries/devguide.html

Free JavaScript: Novice to Ninja Sample

Get a free 32-page chapter of JavaScript: Novice to Ninja and receive updates on exclusive offers from SitePoint.

  • http://techguitar.com drsoda

    You’re welcome ;)

  • http://www.naturmed24.com/schlankheitsmittel-LIDA-Schlankheitstee.html lida dai dai

    There is obviously a lot to know about this. I think you made some good points in Features also.
    Keep working ,great job!

  • http://jijik.com Enedina Bhatia

    Thanks for taking the time to share this, I feel strongly about it and love reading more on this topic. If possible, as you gain knowledge, would you mind updating your blog with more information? It is extremely helpful for me.

  • http://www.radiologytechnicianguide.com radiology technician

    Valuable info. Lucky me I found your site by accident, I bookmarked it.

  • http://www.danceswithgoats.com maria andros

    Really nice post,thank you, best website ever

  • Pingback: How To Setup jQuery in 3 Easy Steps | jQuery4u

  • http://www.forum.talers.ru/index.php?action=profile;u=690;sa=summary jerichoun

    Great blog!!! A++++

  • Pingback: jQuery.com to disable hotlinking | jQuery4u

  • http://www.empirevaletingservices.co.uk Empire Mobile Valeting Services

    Thanks for taking the time to post for people like me, who are just getting into it. This is the first site that i’ve found that shows you step by step how and where to input the codes. Have you got anymore that could help a newbie, as i would like to update my jQuery.

  • Yogesh

    very much important info. nice .