javascript - Can I use multiple versions of jQuery on the same page? -


a project i'm working on requires use of jquery on customers' web pages. customers insert chunk of code we'll supply includes few <script> elements build widget in <script>-created <iframe>. if aren't using latest version of jquery, include (most likely) <script> google's hosted version of jquery.

the problem customers may have older version of jquery installed. while may work if it's @ least recent version, our code rely on introduced functionality in jquery library, there bound instances when customer's jquery version old. can't require upgrade latest version of jquery.

is there way load newer version of jquery use within context of our code, not interfere with, or affect, code on customer's page? ideally, maybe check presence of jquery, detect version, , if it's old, somehow load recent version use our code.

i had idea of loading jquery in <iframe> in customer's domain includes our <script>, seems might feasible, i'm hoping there's more elegant way (not mention without performance , complexity penalties of <iframe>s).

yes, it's doable due jquery's noconflict mode. http://blog.nemikor.com/2009/10/03/using-multiple-versions-of-jquery/

<!-- load jquery 1.1.3 --> <script type="text/javascript" src="http://example.com/jquery-1.1.3.js"></script> <script type="text/javascript"> var jquery_1_1_3 = $.noconflict(true); </script>  <!-- load jquery 1.3.2 --> <script type="text/javascript" src="http://example.com/jquery-1.3.2.js"></script> <script type="text/javascript"> var jquery_1_3_2 = $.noconflict(true); </script> 

then, instead of $('#selector').function();, you'd jquery_1_3_2('#selector').function(); or jquery_1_1_3('#selector').function();.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -