[jQuery] Dynamically reference jQuery and delay execution until it is loaded?
Hi All,
I am struggling to test if a jQuery reference exists yet on a page,
and if it does continue loading my jQuery plugins. However, if it
does not, I wish to add the jQuery reference, and continue loading my
jQuery plugins only after the jQuery script has loaded.
Below is a snippet of what I've tried (which does not work). This
code is in the body tag of my page, and my specific problem is
detecting if a page has already loaded jQuery into the header.
Thanks!
<body>
<div id="global_menu">
<script language="JavaScript" type="text/javascript">
if (!jQuery)
{
//alert("jQuery NOT loaded");
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'jquery-1.2.6.min.js';
document.getElementsByTagName('head')[0].appendChild(script);
}
</script>
<!-- many other jQuery plugins are referenced here, too -->
<script type="text/javascript" src="http://www.elon.edu/e-net/
Scripts/menu/jquery.jdMenu.js" />
<!-- menu source removed for brevity -->
</div>
</body>