Entries (RSS)  |  Comments (RSS)

Improving Javascript Load Times using Google AJAX API

If your site uses common AJAX libraries like jQuery, jQuery UI, mootools, prototype, script.aculo.us, or dojo, the first thing that you’ll notice is that these libraries are quite large and impact page load time.

For a browser with a completely empty cache, the browser will load the requested library (and block all other requests during the load). For every site the user visits, the library is loaded again and again because the cache does not work across sites. Loading site1.com/jquery.js and site2.com/jquery.js takes the same amount of time.

Google’s come up with a clever solution to this problem. Instead of pointing to your local copy of whatever AJAX library you want, you point to Google’s copy using their AJAX Libraries API.

There’s many advantages to this. If the user has been to Gmail or any Google property recently, the library is already loaded in their browser, ready to execute. If the user goes to other sites which use the API, their cache is already primed and does not need to be loaded again. 

We’ve just put this in place over at Twitter, and it should improve page load times dramatically.

This entry was posted on Monday, September 22nd, 2008 at 1:12 pm and is filed under peformance, software engineering, web development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

  • looks like a useful technique I'm already working on something with Ajax, so will definitely gonna try this and comment here about the use.
  • gr
    Hrm. Does Google offer an SLA contract to business that want to use this? I'd be kind of freaked out if I were using this, both on the service availability and the rickrolling potential...
  • saari
    DDLs anyone?
  • Very nice! Thanks for the heads up. I'll definitely send this along to some AJAXers I know.
blog comments powered by Disqus