

JQuery google api and other google hosted javascript libraries. - alexyim
http://scriptsrc.net/

======
Encosia
When using this CDN for versioned libraries like jQuery, be sure to avoid
using the "latest version" references[1][2].

In order for the "latest version" feature to be reliable, they have to avoid
users having stale local copies for very long. Thus, they serve those with a
much closer expires header, which defeats one of the shared CDN's biggest
benefits.

When you reference the full version explicitly[3], it's served with a +1 year
expires header.

// Not cached for long.

[1] <http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js>

[2]
[http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.j...](http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js)

// Cached for up to a year.

[3]
[http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min...](http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js)

~~~
qeorge
Good point. Another reason to do this is that jQuery and other libraries are
not always backwards compatible between point releases, so you can end up with
broken code in the wild without your knowledge.

------
rodion_89
Exactly necessary was it to implement this site in Flash? It's quite a bit of
overkill for such a simple app.

~~~
sumeetjain
I believe getting copy/paste to work across browsers requires a Flash include.

~~~
raganwald
Copy and paste work _just fine_ in all of my browsers without Flash. You show
me some text, I select it and copy it. You can even use fancy Javascript to
select all of the text if I click anywhere on the text you think I want to
copy. Just in case I don't want to press "Command-A."

I don't get the need to gratuitously replicate functionality that's already
dead simple. It's a personal project, so I suppose it's as much art as
engineering. But of this were a business, I would be very interested in some
A/B testing to measure whether you are losing users by not having a one-click
way to copy the script code.

------
nhebb
While the advantage of referencing the google api files is that your browser
can take advantage of cached copies, Google Webmaster Tools recommends
reducing the number of DNS lookups if you do so. I recently worked through all
the PageSpeed and YSlow flags and saw a decent bump in traffic afterward. It
could be coincidence, but I had a long history of stable traffic, so the
timing seemed too coincidental.

~~~
Encosia
ajax.googleapis.com is being referenced on so many sites now that many, if not
most, visitors will have the DNS resolution cached.

~~~
btmorex
Not that I doubt that, but how would you even go about measuring such a thing?
Obviously, there's a cost to using google version too (DNS lookup + one more
point of failure). It would be nice to have real numbers for what percentage
of visitors actually have the libraries cached. Remember, that the files are
versioned and they're also serving less popular libraries than jquery. My
guess is that it would be slower to use the google version for some
library/version combos. The question is which ones.

~~~
Encosia
I ran a crawler on the Alexa top 200,000 a couple months ago, measuring how
many sites referenced jQuery and how many used a CDN. I haven't published the
results yet, but will be sure to submit that post here when I write it.

Keep in mind that the version fracturing doesn't increase the likelihood of a
DNS lookup.

------
marcusbooster
I find this page more convenient:
[http://code.google.com/apis/ajaxlibs/documentation/index.htm...](http://code.google.com/apis/ajaxlibs/documentation/index.html)

~~~
CoryMathews
this page tells you how to use googles javascript to load the library, instead
of providing links directly to the library's.

~~~
marcusbooster
It provides the url for each library.

