Posted By

brandonjp on 07/07/10


Tagged

javascript js textmate check test jquery load if loader jQ


Versions (?)

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


 / Published in: jQuery
 

  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  

You need to login to post a comment.