What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 150 Stack Exchange communities.

Google's CDN is nice, but nothing's 100% reliable for all users. It occasionally fails to load for me. Other users have had trouble with it due to sloppily-configured networks, and some may prefer to block external scripts by default. It's one more possible point of failure. It would be preferable if Stack Exchange didn't depend on it.

I'm not suggesting that you stop using it, but consider adding a fallback if it fails to load. Something like this:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
  if (!window.jQuery) {
    document.write('<script src="https://cdn.sstatic.net/stackoverflow/content/js/jquery-1.7.1.min.js"><\/script>');
share|improve this question
No reason not to have safety nets and backups in place. I like the idea. – chown May 27 '12 at 21:39
+1 Good idea. Some more nice methods for doing this stackoverflow.com/a/6125487/242 – David HAust May 28 '12 at 1:05
Related: meta.stackoverflow.com/questions/258288/… – snailboat Jun 15 '14 at 13:20

2 Answers 2

I dislike this proposal cause it cascades.

What about cdn.sstatic.net? Should we add a fallback to sstatic.net? Perhaps the network is totally disallowing remote resources, what about a second level fallback to stackoverflow.com?

What happens if downloading stuff from Google is taking 30 seconds to time out? Now the fallback is going to be mega delayed.

Personally, I see no advantage in using the Google CDN, our CDN outperforms it usually. With the advantage that the connection can be reused later on in the request. Less CDNs = Less randomness.

Additionally I feel a better investment of our resources would be pushing jQuery to load async, so you can still see the content even if jQuery is not loaded. (Question/Show page does this partially)

Now, some may say that Google CDN version of jQuery is incredibly likely to already be on a machine, the reality is that 20% of our page views have an unprimed cache, empty cache is incredibly likely. People are often clicking "refresh" as well forcing a If-Modified-Since to Google as well.

share|improve this answer
Sure, using cdn.sstatic.net instead of Google's CDN also sounds good to me. It doesn't matter if we can load jQuery when we can't load the scripts that use it. +1 – Jeremy Banks May 28 '12 at 3:51
As an aside: showing a warning when sstatic.net fails to load might also be easily achieved? That's already nicely done for jQuery, but that very check is in code loaded from sstatic.net. So, a warning for sstatic.net needs code from the regular domains themselves. – Arjan May 28 '12 at 5:15
Just curious: "the reality is that 20% of our page views have an unprimed cache" — were you actually somehow measuring the availability of jQuery for those requests? – Arjan May 24 '14 at 15:21
@waffles, I disagree with your first paragraph. The proposal does not need to cascade because there's nothing stopping it from being treated as a case-by-case basis. The question would be whether there's a real observed problem with a majority of visitors. And as for Google's CDN, there's actually such a real problem. Also see Use of ajax.googleapis.com not China friendly. – Pacerier Jul 14 at 5:41
@Pacerier waffles has left the building best as nickcraver or flag it or something – waffles Jul 15 at 6:32
@waffles, Btw what's the reason for your retirement? – Pacerier Aug 5 at 9:24
@Pacerier too much maple syrup. – waffles Aug 5 at 9:25
@waffles, Ok.. I'd not quite have the context here.. – Pacerier Aug 5 at 10:05
@Pacerier I wrote a blog post about why I left years ago, not really on topic here. – waffles Aug 10 at 5:31

I think this is a good idea. As a Chinese visitor I'd like to use jquery cdn from baidu.The url is http://libs.baidu.com/jquery/1.11.1/jquery.min.js

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .