3 ms·
Backward compatibility. Millions (if not hundred of millions) of websites rely on jQuery, switching to a newer version that breaks old code will wreak havoc an
by csomar 15y ago
Backward compatibility.
Millions (if not hundred of millions) of websites rely on jQuery, switching to a newer version that breaks old code will wreak havoc and make these sites unusable.
But this shouldn't stop jQuery from improving. If you have read the article from the beginning, you'll see how the jQuery team was improving the binding functionality. It has a cost, certainly. Maybe there should be a jQuery version with no legacy code.
- davej 15y agoYep, the best advice for a newcomer is to just use `.on()` and familiarise yourself with that API. You can ignore the other event handler methods because they're all just shortcuts or legacy methods.
- dmethvin 15y agoExactly. It would simplify the documentation to simply deprecate everything but .on() but would that justify breaking all the existing code out there? Not to me. The old APIs need to stay around so that code continues to work.
- cgoddard 15y agoThey could deprecate the old methods and still keep them around as long as makes sense. There's no rule that deprecated methods have to be gotten rid of during the next major revision or anything.
- cgoddard 15y agoEven if they excised the old methods from the code, hopefully no one is linking to jQuery trunk or something as their primary library. The old versions would still be around. Just some simple work might have to be done to update a web app to using the latest versions of jQuery.
- emehrkay 15y agoI like MooTools. When they added event delegation to their library, they simply modified the existing addEvent method to parse the event name instead of adding new method after new method -- seems like a more thought out approach. $(selector').addEvent('click:relay(selector)', fn)
- emehrkay 15y agoThe overall api is strange. The each loops are backwards from the spec (key, value) instead of (value, key) and there are instances where it is key, value in jquery, there are instances where method names just don't make sense (I'd expect something like size to be dimensions etc), getters and setters as the same method, way too much argument overloading, inconsistent approach (selector.action, but wrap is the opposite of how the rest of the lib works). There is no kind of inheritance for their plugin architecture. These are just things off the top of my head. I feel like jQuery is the same as PHP when it comes to api, and I make a living doing PHP.
- mark_story 15y agojQuery.map() jQuery.each() having their arguments has caused me more than a few WAT moments. One way I solve the issue around overloaded apis is by not using them. I just pretend .click() and friends just don't exist.
- prolepunk 15y agoYet it breaks hilariously when you try to move from 1.3.2 to 1.4.4. I still have ONE script for which I have to deal with jquery-1.3.2.
- jonknee 15y ago> Maybe there should be a jQuery version with no legacy code. They're deprecating stuff, so it's just a matter of time. I think that's the sensible way to do things. http://blog.jquery.com/2011/11/08/building-a-slimmer-jquery/ http://blog.jquery.com/2011/11/08/building-a-slimmer-jquery/ They're also taking steps to be able and use Google Closure Compiler's advanced optimizations, which would let you build jQuery against your code and trim out everything that's not used. Pretty handy.
- nfriedly 15y ago> They're also taking steps to be able and use Google Closure Compiler's advanced optimizations... That is awesome, thanks for pointing it out!
- jacobr 15y agoA 2.0 release would be a reasonable point to potentially break legacy code.