aneuryzm
aneuryzm

Reputation: 64834

jQuery: running 2 different jQuery versions on the same website?

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!

Upvotes: 1

Views: 356

Answers (3)

Tom
Tom

Reputation: 1057

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

Upvotes: 0

Ramuns Usovs
Ramuns Usovs

Reputation: 1454

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

Upvotes: 2

Tahbaza
Tahbaza

Reputation: 9548

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...

Upvotes: 2

Related Questions