News for hackers. Stuff that matters.
Re:6,953 reasons why I still let Google host jQuery for me by nphase on Tuesday September 21, 2010 @04:14PM (#1713954)
I used to let Google host jQuery for me. And then one day their CDN went down for a large chunk of the midwest (where I live), and I noticed the render time of my site (and a few others) jump up anywhere between 5x and 100x.

That was the moment I resolved never to leave critical, blocking elements of any site I run into the hands of others, no matter how well known or reliable they are. (FWIW, this also includes ad network invocation scripts and similar, which always seem to be notoriously slow to load).

Re:6,953 reasons why I still let Google host jQuery for me by lsb on Tuesday September 21, 2010 @04:47PM (#1714067)
One of the major problems involved with using third-party login systems, like Facebook Connect, is exactly that: you need to make sure it's not critical (so you need your own login system anyway) and you need to make sure it's not blocking (which involves iframe shenanigans).
Re:6,953 reasons why I still let Google host jQuery for me by Encosia on Tuesday September 21, 2010 @04:26PM (#1713996)
I decided it's outside the scope of that post (which was already laboriously long winded), but you can/should use a fallback technique like this to mitigate the potential for Google downtime: http://weblogs.asp.net/jgalloway/archive/2010/01/21/using-cd...

Also, HTML5 Boilerplate has that built-in: http://html5boilerplate.com/

Re:6,953 reasons why I still let Google host jQuery for me by vog on Tuesday September 21, 2010 @08:50PM (#1714753)
This technique doesn't address the right problem, which might be a misunderstanding in statistics.

That is, no matter how reliable the other source (Google etc) is, it is still below 100%. If you host the JS on your own, your site becomes slow only if your server hangs. However, if you host the JS somewhere else, your site becomes slow whenever your server or the other server hangs. The probability of the latter is always greater than the former, i.e. you don't really gain anything.

So this trick slightly improves the good cases, but increases the likelihood of the bad cases. That kind of trade-off isn't desirable. Usually, people design trade-offs for the exact opposite: scarifying the speed of the normal case (which should be more than fast enough anyway) in order to decrease the probability of the worst case.

(BTW, this is true for almost all long-living projects. The opposite strategy makes only sense in "car racing" like situations where you either win fast, or lose everything. However, hardly any website is designed to live only a few weeks or so.)

Re:6,953 reasons why I still let Google host jQuery for me by Lozzer on Wednesday September 22, 2010 @07:07AM (#1715756)
Hosting jquery on your website increases the load on your website, this increasing the probability that your website will fail.

The more sites that use the CDN, the more likely someone coming to your site already has jquery in their cache.

If you're just trying to minimize downtime, regardless of cost then I absolutely agree with your analysis. However if you're trying to minimize something more complex involving downtime and cost, then maybe there's a point where it makes sense to use the CDN. Something very high volume like Twitter, for example.

Re:6,953 reasons why I still let Google host jQuery for me by points on Tuesday September 21, 2010 @04:28PM (#1714004)
The fallback technique does nothing to mitigate the "It can connect but loading takes forever" case surely.
Re:6,953 reasons why I still let Google host jQuery for me by sounddust on Tuesday September 21, 2010 @04:38PM (#1714036)
I've thought to myself, "I wish there was a timeout attribute on the <script> tag," about once every few months for the past 10 years. Is there any good reason you can't manually specify how long you want the browser to wait for an external file to load?
Re:6,953 reasons why I still let Google host jQuery for me by stellar678 on Wednesday September 22, 2010 @01:02AM (#1715226)
There's no reason you couldn't code this up in JavaScript:

  load jquery from google
    - onload, set flag jquery_loaded
  settimeout load_locally_if_not_flag 5sec
Re:6,953 reasons why I still let Google host jQuery for me by toolate on Wednesday September 22, 2010 @08:19AM (#1715868)
Don't forget that JavaScript is blocking. You'd need to load the jQuery from Google dynamically by inserting script tags.

By the time you've added that, timeouts and fallbacks the amount of inline JS would make hosting jQuery on a CDN pointless.

Re:6,953 reasons why I still let Google host jQuery for me by blasdel on Tuesday September 21, 2010 @06:11PM (#1714294)
You can at least control the degree of blocking in the latest Webkit: http://webkit.org/blog/1395/running-scripts-in-webkit/
Re:6,953 reasons why I still let Google host jQuery for me by eli on Tuesday September 21, 2010 @06:27PM (#1714341)
I believe FFox 3.6 supports async attribute as well
Re:6,953 reasons why I still let Google host jQuery for me by Encosia on Tuesday September 21, 2010 @04:31PM (#1714015)
You're correct.

That fallback technique mitigates the majority of failure cases though (NoScript, overbearing firewall, blocked regions, etc). The CDN itself being slowly-down is vanishingly rare.

Re:6,953 reasons why I still let Google host jQuery for me by techiferous on Tuesday September 21, 2010 @06:14PM (#1714301)
"The CDN itself being slowly-down is vanishingly rare."

Based on...?

It happened to me once a few months ago. It was down for hours. The negative impact was very real and painful and in my opinion outweighed the other advantages of hosting using Google's CDN.

Re:6,953 reasons why I still let Google host jQuery for me by Encosia on Tuesday September 21, 2010 @10:14PM (#1714953)
Pingdom tested Google, Microsoft, and Edgecast's jQuery CDNs every minute for a couple weeks and found all of them averaged between 100-150ms to download jQuery[1]. Google's was actually the slowest of those, averaging a turtle's pace of ~130ms from all of Pingdom's datacenters. They're all so close that the Google CDN's overwhelming caching advantage should be preferable though.

More anecdotally, I've been running a few Pingdom type tests myself for a longer period, using uptime tools on few of my servers and mon.itor.us. Except for that brief outage the morning of May 14, 2009[2], I haven't monitored a net-wide outage or even a 250+ ms slowdown.

I'd be genuinely interested in any concrete data to the contrary.

[1] http://royal.pingdom.com/2010/05/11/cdn-performance-download...

[2] http://www.zdnet.com/blog/btl/cloudy-day-google-falters-pack...

Re:6,953 reasons why I still let Google host jQuery for me by techiferous on Tuesday September 21, 2010 @10:40PM (#1714999)
June 18th, 2010 was when Google's jQuery went down for me (and many other people).
Re:6,953 reasons why I still let Google host jQuery for me by points on Tuesday September 21, 2010 @05:49PM (#1714223)
I don't know, anecdotal evidence here, but the majority of cases I see pages taking a long time to load due to 3rd party js etc, it's waiting for actual data, rather than anything else.

The OP said:

"and I noticed the render time of my site (and a few others) jump up anywhere between 5x and 100x."

Which would indeed suggest that it did load, but at significantly reduced speeds.

Re:6,953 reasons why I still let Google host jQuery for me by Encosia on Tuesday September 21, 2010 @09:53PM (#1714894)
These highly-available, distributed CDNs hosting static content don't have the same failure characteristics as something like an advertising script or Twitter widget. Where the latter do often hang the page (frustratingly), the popular CDNs that host jQuery aren't prone to that under any but the rarest of circumstances.

Maybe unrelated, but you'd be surprised how often the "Waiting for domain.com..." in your browser's status bar is misleading. Interactions between externally referenced scripts, images, and scripts that use document.write can produce "interesting" results in most browsers.

Re:6,953 reasons why I still let Google host jQuery for me by ciupicri on Tuesday September 21, 2010 @05:34PM (#1714181)
But aren't these kind of events pretty rare?
Re:6,953 reasons why I still let Google host jQuery for me by vog on Tuesday September 21, 2010 @08:58PM (#1714771)
As long as their probability is greater than 0%, they inevitably do more harm than good.
Re:6,953 reasons why I still let Google host jQuery for me by ciupicri on Tuesday September 21, 2010 @10:55PM (#1715021)
The same thing can be said about other services and I doubt that Joe's hosting service availability is better than Google's. Though I admit that if Google fails and at the same time your site doesn't, it sucks.
Re:6,953 reasons why I still let Google host jQuery for me by mike-cardwell on Wednesday September 22, 2010 @04:22AM (#1715528)
If your website is up, your locally hosted jquery is up.

If your website is up, your CDN hosted jquery is not necessarily up.

That was his point.