Nazmul
Nazmul

Reputation: 7218

Google CDN for jquery or prototypejs or any other if not loaded

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.

EDIT

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

Answers (2)

alex
alex

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

sarp
sarp

Reputation: 3750

have a look at this

Upvotes: 2

Related Questions