My favorites | English | Sign in

Google Libraries API

Google Libraries API - Developer's Guide

The Google Libraries API is a content distribution network and loading architecture for the most popular, open-source JavaScript libraries. Using the google.load() method gives your application high speed and global access to a growing list of the most popular, open-source JavaScript libraries. You can also use <script> tags to include the libraries.

Table of Contents

Audience
Introduction
Load the API
Versioning
Available Libraries
Chrome Frame
Dojo
Ext Core
jQuery
jQuery UI
MooTools
Prototype
script_aculo_us
SWFObject
WebFont Loader
Troubleshooting

Audience

This documentation is designed for people familiar with JavaScript programming and object-oriented programming concepts. There are many JavaScript tutorials available on the Web.

Introduction

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.

Load the API

To begin using the Libraries API, include the following script in the header of your web page.

<script type="text/javascript" src="https://www.google.com/jsapi"></script>

Next, you load the libraries. The preferred method is to load the libraries via standard <script> tags (as in <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>, which will result in the fastest loads.

You can also load any number of libraries via google.load() as follows:

  google.load("chrome-frame", "");
  google.load("dojo", "");
  google.load("ext-core", "");
  google.load("jquery", "");
  google.load("jqueryui", "");
  google.load("mootools", "");
  google.load("prototype", "");
  google.load("scriptaculous", "");
  google.load("swfobject", "");
  google.load("webfont", "");

As you can see in the code snippets above, the first argument to google.load is the name of a library. The second argument is a version specification. The complete list of libraries is a growing collection of the most popular, open-source JavaScript libraries.

Note: If you choose to load libraries with google.load, you also need to set google.setOnLoadCallback.

You can find out more about google.load in the Google Loader developer's guide.

Versioning

google.load gives you two ways to specify which version of the library you wish to load. You can request:

  • A specific version (such as google.load("jqueryui", "1.8.2");, which loads that exact version of the library (in this case, version 1.8.2).
  • A truncated version (such as google.load("jqueryui", "1");, which loads the most recent version in that branch (in this case, 1.8.2).

Libraries

Each library is available via both google.load() and directly, via a <script> include. The google.load() approach offers the most functionality, while additional performance is gained by using the <script> tag approach.

The following section lists all of the libraries currently supported by the API. We list the library name (the name used in google.load()) and all of the supported versions.

Troubleshooting

If you encounter problems:

  • Look for typos. Remember that JavaScript is a case-sensitive language.
  • Use a JavaScript debugger. Google Chrome has a full set of developer tools. In Firefox, you can use the JavaScript console or the Firebug. In IE, you can use the Microsoft Script Debugger.
  • Search the discussion group. If you can't find a post that answers your question, post your question to the group along with a link to a web page that demonstrates the problem.