11 JulWhat if Google CDN is down?
Monday, 11 July 2011 — 10:21You can find in the web some of the advantages of using CDNs (Content Delivery Network) for loading static files such as jQuery ones. The most important ones are browser cache and parallels connections. But this is not the goal of the post.
Here, i will try to answer the question: What if Google CDN is down?. I’m saying Google because it is by far the most used CDN.
You will have to tweak your javascript include tags in a way that it loads local copies of the library if that happens.
Here you go an example:
<!-- Grab Google CDNs jQuery; fall back to local if necessary --> <%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"%> <%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"%> <script>window.jQuery || document.write(unescape('%3Cscript src="/javascripts/jquery.min.js"%3E%3C/script%3E%3Cscript src="/javascripts/jquery-ui.min.js"%3E%3C/script%3E'))</script>
Ger
11 Jul 11:29
Bajo mi punto de vista, mas elegante y mas seguro.