views:

51

answers:

3

can I run 2 different jQuery versions on the same website and avoid conflicts ?

please don't ask me why.. it is a long story.

Thanks!

+2  A: 

Your html knows only know what you tell it, so if you have something like this in your HEAD section

<script src="<%= Url.Content("~/Scripts/jquery-1.4.2.min.js")%>" type="text/javascript"></script>

instead of the below on a given page in your website there shouldn't be a problem.

<script src="<%= Url.Content("~/Scripts/jquery-1.3.2.min.js")%>" type="text/javascript"></script>

However, I would not try to reference both versions from any given page as I would expect that to invite method name collisions...

Tahbaza
+1  A: 

well it should be possible, you will have to update your scripts though.

The idea is not all that difficult: include the least often used version first

then add this script

<script type="text/javascript">
   window.jQueryOld = jQuery;
</script>

then add the more often used version.

now you only have to update your scripts that use the old (or new version withchever it is) to use not the $ or jQuery variable, but the jQueryOld variable

Ramuns Usovs
You probably should add jQuery.noConflict(); to start of the script block, to release control of `$` variable.
che
A: 

Different versions you would get problems. define the includes in the head. You can use obviously different plugins/addons.

Tom