Conditionally load jQuery

Posted by & filed under Javascript.

<script type="text/javascript">
// load jQuery if not already loaded
if (typeof jQuery == 'undefined') {
   var head = document.getElementsByTagName("head")[0];
   script = document.createElement('script');
   script.id = 'jQuery';
   script.type = 'text/javascript';
   script.src = 'pathto/jQuery/jquery-1.5.1.min.js';
   head.appendChild(script);
}
</script>

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Bitnami