Reputation: 7218
I am using google CDN for jQuery and prototypeJS library in my pages. For any reason, if those library are not loaded what measure can I take so that my pages function properly.
I have found this link in SO
Best way to use Google's hosted jQuery, but fall back to my hosted library on Google fail
which is very similar to my question.
Sorry to ask the same thing which has been asked already.
Upvotes: 0
Views: 560
Reputation: 490173
if (typeof jQuery == 'undefined')) {
// Insert your local copy
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'to/local/copy/jquery.js';
var scriptHook = document.getElementsByTagName('script')[0];
scriptHook.parentNode.insertBefore(script, scriptHook);
}
Upvotes: 1