js - jQuery - jQueryLoader - check if $ is undefined, then load jquery with pure javascript if needed


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



Copy this code and paste it in your HTML
  1. /* I used to use (!$) or ($ == undefined) but that doesn't work sucka! */
  2.  
  3. if (!window.jQuery) {
  4. var jqscript = document.createElement('script');
  5. jqscript.setAttribute("type", "text/javascript");
  6. jqscript.setAttribute("src", "http://code.jquery.com/jquery.min.js");
  7. document.getElementsByTagName("head")[0].appendChild(jqscript);
  8. };

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.