4 ms·
Performance. Many of your visitors will already have it in their cache.
by dminor 16y ago
Performance. Many of your visitors will already have it in their cache.
- mootothemax 16y agoMy concern has always been the one-day-in-a-thousand when the CDN will be down and so my sites won't work. When my sites go down it doesn't matter as the entire package stops working, but I'd hate myself ten times more if things stopped working due to an admittedly extremely rare CDN failure. That said, I'm open to the idea that I'm being extremely foolish about this ;)
- adamdecaf 16y agoMost users will have the javascript in their cache anyway, so they won't even be hitting the CDN. Also, why not check to see if the object exists before doing anything else? <script id="jquery" src="http://code.google.com/jquery.js"></script> <script> if (jQuery == undefined) { document.querySelector("#jquery").src = 'Backup CDN'; } </script> That should work, in theory, if not then just remove script#jquery, create a new one and append to the document before executing any script(s).
- mootothemax 16y agoIt's at times like this that I feel really stupid ;) Thanks, you can guess what I'll be changing on my sites the minute I sobered up, err, sometime in the next couple of days ;)
- catshirt 16y agoiirc changing the src attribute directly does not resend the request (in at least some browsers). you need to create a new node.
- wizard_2 16y agoStolen from the html5 boilerplate <!-- Grab Google CDN's jQuery. fall back to local if necessary --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script> <script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.4.2.js"%3E%3C/script%3E'))</script>
- mootothemax 16y agoSuperb, thank you! I'm more feeling significantly more enlightened :-D