Thursday, May 29, 2008

Reduce your server load by using Google hosted open source javascript libraries

When building a medium- to heavily-used webapp a common best practice is to separate the static content (static html, images, javascript files) from the dynamic content, then have the static content served up by Apache/IIS or even a web cache. Generally you try to off load whatever content you can from your dynamic content server to something that can handle static content more efficiently.

If you are using one of the common open source javascript libraries like Dojo, prototype or jQuery you'll have to bundle a copy of said library with your application, which of course will be downloaded to the browser from your website because browsers are not smart enough to realize that "I already downloaded and cached Dojo version 1.1 from another website I looked at recently".

Wouldn't it be great if a company with a reputation for high availability and lots of bandwidth hosted some of the common javascript libraries so that your website and others could benefit from caching? Well, Google AJAX Libraries API provides such a service. A downside of course is that Google could track some of the users of your website :)

No comments: