Hacker News new | comments | show | ask | jobs | submit login
JQuery google api and other google hosted javascript libraries. (scriptsrc.net)
40 points by alexyim 2514 days ago | hide | past | web | 13 comments | favorite



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...

// Cached for up to a year.

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


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.


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


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


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.


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.


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


Exactly. It would be nice if GWT and PageSpeed took that into account because they're sending mixed messages.


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.


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.



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


It provides the url for each library.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: