3 ms·
Most 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 a
by adamdecaf 16y ago
Most 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.