Saving Bandwidth Made Easy: Google Data JavaScript Packaging
September 29th, 2008 | Published in Google Code
At Google, we believe it’s important to conserve limited resources, whether it’s the environment or bandwidth. While it won’t help with global warming (we have other projects for that), our new support for packages in our Google Data JavaScript client library can help with the bandwidth.
This feature allows you to specify precisely which Google Data services you’ll be using in your applications. We then use this information to send just the library code you need, leaving out all the rest. Less code sent across the wire means faster page loads for your applications. Faster page loads mean happier users.
For comparison, the current version of the JavaScript client library is 47 KB in size. If you request only the Blogger package, that library shrinks to 37 KB, a 21% reduction.
To take advantage of this, just add a packages argument when you’re loading the client library. For example, the following statement would request only the code necessary for working with the Blogger and Contacts APIs:
google.load("gdata", "1.x", { packages : ["blogger", "contacts"] });
If you don’t specify a packages argument, you’ll receive all available packages, just as before. This means that your old code will continue to work just as it is.
If you have any questions, feel free to drop by our discussion groups where you’ll find other developers ready to lend a helping hand.