DailyJS

Why You Should Get Your JS from Google

Ric Roberts

Subscribe

@dailyjs

Facebook

Google+

google performance

Why You Should Get Your JS from Google

Posted by Ric Roberts on .
Featured

google performance

Why You Should Get Your JS from Google

Posted by Ric Roberts on .

If you're using popular JavaScript libraries such as
jQuery, Prototype, Scripty, or MooTools, and you're not taking advantage of Google's Ajax
Libraries
content delivery
service, then you might be missing a trick.

By using Google's Ajax Libraries, you get some of the benefits of a
CDN -- lower latency
requests no matter where your users are.

You also get better caching: it's probable your users will already have
the JavaScript file in their browser cache from another site and so
won't have to re-download it.

You can load a library by using Google's AJAX loader. If you provide a
partial version number, Google will dish up the latest version that
matches the pattern. The example below would load v1.3.2 if called today
(but so would using "1.3"). This is useful if you're relying on features introduced by a certain version.

  // Load jQuery
  google.load("jquery", "1");

Or, you can just reference a particular version's file directly (which
will result in fewer requests).