Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives to changing code that uses deprecated jQuery methods

Tags:

jquery

Are there any alternatives when working with deprecated methods in jQuery?

Instead of changing the code, are there any compatible migration tools that make all the versioning issues go away?

like image 901
madhuchenna Avatar asked Aug 01 '13 09:08

madhuchenna


2 Answers

Here it is :)

The jQuery migrate plugin Might help you :)

This plugin will give support for the deprecated functions.

Note that this plugin is meant for Migration purposes only! The deprecated functions are deprecated for a reason!

like image 66
AmazingDreams Avatar answered Oct 12 '22 21:10

AmazingDreams


The jQuery Migrate Plugin is very helpful in upgrading from versions 1.6.4 to 1.9+. Anything below that and you may have handle the bugs on your own. When I upgraded our project from jQuery 1.4.2 to jQuery latest, I stepped up through each minor release and checked the release notes (e.g. for 1.5.2) as I went along. One of the issues I found which won't be supported with the jQuery migrate plugin is the addition of the .prop() method, and the new meaning of the .attr() method.

The main issue for me when I upgraded jQuery was changing all of my .live() events to .on(), and this plugin really helped me with that. It'll also tell you that support for the $.browser method has gone, though it'll offer no real solution other than using a tool like modernizr and use feature-detection methods instead.

The way I went about using the script, was to download it from here, and add it to your pages. Note: there are two versions of the plugin, one for development and one for production. Both try to iron out any depreciation issues, but the development on will also notify you about each of them through the console (each starts with JQMIGRATE). Given that you seem to be just asking for support for depreciated methods, I'd use the production version but you should seriously try to replace all of your depreciated code, as modern jQuery offers some serious performance improvements* - most notably in jQuery 2, where support for legacy IE (<=8) has been dropped.

* A number of tests, but jQuery 1.8/1.9 wins in all of them for me

like image 32
Ian Clark Avatar answered Oct 12 '22 20:10

Ian Clark