If you are developing web applications and need to use javascript libraries from time to time you probably allready have read about the Google AJAX libraries API, which enables you to include nearly any javascript library with only two lines of code. You don't have to include the libraries into your package anymore.
As this is such a usefull solution we decided to write a short instruction how to use the Google AJAX libraries API for those who might have missed that opportunity.
{xtypo_quote}The AJAX Libraries API is a content distribution network and loading architecture for the most popular, open source JavaScript libraries. By using the Google AJAX API Loader's google.load()
method, your application has high speed, globaly available access to a growing list of the most popular, open source JavaScript libraries.
Google works directly with the key stake holders for each library effort and accepts the latest stable versions as they are released. Once we host a release of a given library, we are committed to hosting that release indefinitely.
The AJAX Libraries API takes the pain out of developing mashups in JavaScript while using a collection of libraries. We take the pain out of hosting the libraries, correctly setting cache headers, staying up to date with the most recent bug fixes, etc.{/xtypo_quote}
First of all you have to enable the Google AJAX libraries API with the following code:
{xtypo_code}<script src="http://www.google.com/jsapi"></script>{/xtypo_code}
The second and allready the last step is to load the library itself and specify a version if desired, for example jQuery v1.2.6:
{xtypo_code}<script type="text/javascript"> google.load("jquery", "1.2.6"); </script> {/xtypo_code}
The versioning is optional and if left blank it will load the highest versioned release available. You can also only specify the sub version and it will then choose the highest versioned release of that series, for example "1.8" would load version 1.8.4 if that is the highest .8 version the moment and "1" would load v1.9.1 if that is the highest version overall.
The available libraries are (in the current versions):
{xtypo_code} google.load("jquery","1.3.2");
google.load("jqueryui","1.7.1");
google.load("prototype","1.6.0.3");
google.load("scriptaculous","1.8.2");
google.load("mootools","1.2.2");
google.load("dojo","1.3.1");
google.load("swfobject","2.1");
google.load("yui","2.7.0"); {/xtypo_code}
Googles Developer's Guide