Re:Facebook broke the internet
by AznHisoka on Saturday February 04, 2012 @12:12AM
(#3550313)
I'm still awaiting the day when the Google CDN version of JQuery goes down.
[ Parent
| on HN ]
Re:Facebook broke the internet
by simonsarris on Saturday February 04, 2012 @12:26AM
(#3550353)
In case others are wondering, its quite easy to make a "fallback" when using CDN scripts. For instance:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script>
<script>window.jQuery || document.write("<script src='js/libs/jquery-1.6.4.min.js'></script>")</script>
Could save all such sites that rely on Google CDN jQuery
Re:Facebook broke the internet
by FlemishBeeCycle on Saturday February 04, 2012 @12:29AM
(#3550363)
That's been one of my concerns, the best way to circumvent that issue is to do something like the following:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write(unescape("%3Cscript src='/path/to/jquery.js' type='text/javascript'%3E%3C/script%3E"));</script>
This way it will fallback to a local copy if Google's goes down.[Edit: simonsarris replied with something similar as I was replying, however, the advantage of using unescape is that you don't get invalid markup warnings]
It happened almost a year ago!