Edentity Web Systems
You solve creative. We crack code.
/Header/WhoWeAre.jpg
 

05/07/2009 Load jQuery Dynamically
Posted by Joel Varty

Sometimes you have to load jQuery, but you don’t know if it has already been referenced somewhere else in the website. 

This tends to happen if you have a custom web control, delivered in an assembly, that relies on jQuery.

This code has been ripped out of my application, and may have a typo or three, but it gives you the general idea.

var jQueryScriptOutputted = false; function initJQuery() { //if the jQuery object isn't available if (typeof(jQuery) == 'undefined') { if (! jQueryScriptOutputted) { //only output the script once.. jQueryScriptOutputted = true; //output the script (load it from google api) document.write("<scr" + "ipt type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></scr" + "ipt>"); } setTimeout("initJQuery()", 50); } else { $(function() { //do anything that needs to be done on document.ready }); } }
initJQuery();

« Back to Blog Main Page |

0 Comment(s)

Leave Comment

Name:
Comment:  
 
Security Check: 
 
 
Edentity Web Systems Inc.
Suite 201
40 Spadina Ave.
Toronto ON
M5V 2H8
Tel:
416.591.2500
Fax:
416.352.5270
Home | Who We Are | What We Do | Clients & Brands | Careers | Contact

Copyright © 2010 Edentity Web Systems Inc. Privacy Policy