4 ms·
Best of both worlds: <script src="//example.cdn.com/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="scripts/jquery.min.js"><\/sc
by 9point6 12y ago
Best of both worlds:
<script src="//example.cdn.com/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="scripts/jquery.min.js"><\/script>')
</script>
- gondo 12y agoand what about CSS? the link in the initial post shows that CSS is not available via CDN, not JS
- acoyfellow 12y agohttp://stackoverflow.com/questions/10537039/how-to-determine-if-css-has-been-loaded http://stackoverflow.com/questions/10537039/how-to-determine...
- youngtaff 12y agoArgh, No! That assumes there's a clean fail on the initial request for jQuery i.e. it returns a HTTP error. What happens when the webserver just doesn't respond? DOM construction is just going to wait until the browser times the connection out before it starts to download the fall back (know as a 3rd Party SPOF) The time out is 30 seconds plus so essentially the page is broken from the user perspective.
- leke 12y agoPerhaps a deamon on your server that pings the cdn every minute and checks whether it's down? If it is, you can flip a switch that tells the code to use the local repositories until the service is back up.