jQuery dynamic loader - load jquery using pure js javascript if jQ is undefined or does not exist

/ Published in: jQuery
Save to your folder(s)

Copy this code and paste it in your HTML
  1. // jQuery dynamic loader - load jQuery using pure javascript js
  2. // if jQuery is undefined or does not exist, then load it
  4. if ( !window.jQuery ) {
  5. var jqscript = document.createElement('script');
  6. jqscript.setAttribute("type", "text/javascript");
  7. jqscript.setAttribute("src", "http://code.jquery.com/jquery.min.js");
  8. document.getElementsByTagName("head")[0].appendChild(jqscript);
  9. };

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.