Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm still awaiting the day when the Google CDN version of JQuery goes down.


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


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!

http://news.ycombinator.com/item?id=2398095


doomsday




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: