About fallback for CDN

8

Some people recommend using the following technique ( fallback ) to load Javascript libraries locally if the CDN is out of the loop:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="jquery.js"><\/script>')</script>

My question is: If the CDN is really off the air, will not the browser take several seconds to consider timeout and load the local version? This would make the navigation slow, because with every page change it would try again.

    
asked by anonymous 25.07.2014 / 13:10

1 answer

5

In most types of downtime , yes , the page will be slow, but at least it will work .

If downtime is a type that responds quickly to unavailability, such as an internal error, this will resolve quickly.

When downtime of google servers occurs, it is very common to see services such as airfare purchase ceasing to work, so your fallback is well valid, such as damage containment .

    
25.07.2014 / 13:59