Google Libraries API

Should I use Google’s CDN-hosted jQuery?


Google Libraries API

  1. Cacheing. Google is huge, and people spend more time on other sites.  Chances are by the time they get to your site, they’ve already got a copy of your Google-hosted scripts cached in their browser.
  2. Speed. There’s the obvious facts of Google’s massive worldwide content distribution network, Google’s hosted libraries are served from cookieless domains and gzip compressed.  But here’s the really cool one people don’t notice as much: no 304 responses.  Google serves you jQuery with appropriate headers that tell your browser not to even bother checking if there’s a fresher copy on the server (there isn’t, if there is it’s served from a different URL).  That’s at least 1 less HTTP request that the browser needs to make to load the page.  Fast.
  3. Parallelized downloads (aka pipelining).  Browsers typically make 2-8 (usually about 4) requests from a single domain at a time.  As each request finishes it initiates the next request.  So for a browser making 4 concurrent requests, each taking 100ms it will take you 300ms to load 10 pieces of content.  If 2 of those requests are made to a different domain, then it reduces the time to 200ms.  Pipelining gives you exponential speed increases, and since some of your files are hosted on a different domain you will gain speed from parallelization.

Find out more.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s