Modifying Existing Website to work with two different versions of jQuery

Hi Guys,
I have been working with a 3rd party vendor that has provides us ways to incorporate some widgets from their website. The widgets contain a bunch of javascript which works with jquery 1.7.2.(loaded within their code) My application still uses 1.4.2. I don’t have enought time to update this right now.

Only solution I know is to define a custom variable as $j123 = jQuery.noConflict(true);

My question is, if I do the above, I will have to update all my javascript across the website to work with $j123 instead of the default jQuery and $. Is that correct? If so, it might be easier to update smaller functions but my main concern is how would this effect bunch of plugins that I’m using on the website, there is good about 10 of them e.g

(function($){$.fn.jcarousel=function(…)(jQuery);

Would it mean that I will have find / replace all instances of $ and jQuery in the plugins?

Please advise.

Thanks

Hi there,

What exactly is the problem?
Are you saying that by including jQuery 1.7.2 on your page, it is breaking some of your code written using 1.4.2?

No conflict mode is used to have jQuery relinquish control of the $ alias, not (AFAIK) to have two versions of jQuery play nice together.

Thanks for your reply.Their Jquery and scripts are loaded first in the pages. My scripts and jquery loads afterwards. They are using jquery UI as well e.g jquery UI Tabs. I get an error like JQuery does not contain a method “Tabs” caused by this line: jQuery(“element id”).Tabs()
The error goes away if I remove my scrilts amd Jquery. So i beleive its looking for the tabs function which is tied to their jquery loaded first and when my jquery loads it takes control of the $ and. JQuery variable which does not have the “Tabs” function.

It sounds to me like one version of jQuery is overwriting the other.
Try just removing the jQuery version which is included second - you should only include the library on the page once anyway :slight_smile:

If this doesn’t work, could you post a link to the page in question?

Yes that is the issue and yes if I remove my jQuery then that error goes away but then I have other errors caused by my scripts that were written for 1.4.2 (probably will upgrade next year sometime) but don’t have the time right now. So I will have to load both. i apologize I won’t be able to post a url for privacy reasons.

So what is the best solution if I need to use both so all the scripts (theirs and mine) work ?

Without seeing the code, it’s basically impossible to say.
Sorry :frowning:

BTW, loading both is very counter productive as they will overwrite each other and cause errors.
The browser cannot distinguish between versions of jQuery.

You can only use one version of jQuery per web page.

The only solution if you have scripts that require different versions is to put them on different web pages.

This is true, but I’m still struggling to think of something that broke badly between 1.4 and 1.7
Chances are if the OP showed us their code, we could help get it working.