jQuery Version Conflict

Hello,

May be my question sound stupid, but I need some guidance in this case. I usually download the latest jQuery whenever I work on a new project etc. But let say in a year or so, when there is an upgrade etc required, I come to know that there is a new version of jQuery available, however, many things are no longer supported OR if supported they are changed.

For example, .live was replaced by .on, .attr was replaced by .prop etc.

Now, if I take the recent jQuery file and then run my application - it will break as I have used .live OR .attr everywhere, and its not easy to replace these in all the codes - as there are 100s of files.

What would you people suggest in this case and how normally such cases are solved ? 1 way is to keep using the older jQuery file. But what if I have been using it from CDN ? Also, I don’t think that keeping older version is good because new libraries/plugins does not have supports for them.

Today - a client contacted me after 2-3 years, I used jQuery 1.4 for his project etc, and now there are some big changes etc and I have to use some plugins but they support jQuery 1.8+ - Now I am stuck what to do as i have used .live everywhere.

Please guide
Regards
ZH

True if you edit the files manually one-by-one

BUT
If you use a text editor / IDE that has a “replace all” feature you can replace all occurrences in all your files very easily.

In fact, almost too easily.
Be extremely careful and think long on what string you’re targeting to replace eg.

if you want to change attr don’t replace “attr” with “prop”, rather, replace “.attr(” with “.prop(”

And save back-ups !!!

You could try loading the jquery-migrate plugin. It many cases, old plugins can continue to work with newer version of jQuery that way.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.