The deprecation of jQuery live
AS of jQuery 1.7 the .live method is deprecated.
For a while, I used to interchange the .live method method with .delegate. It wasn’t until I delved deeper into javascript did I realise the error of my ways.
So what is .live anyway?
Description: Attach an event handler for all elements which match the current selector, now and in the future.
Straight from the jQuery docs. Essentially it lets you attach a handler to an element even though it’s not in the DOM yet.
In essence it sounds like a really simple function, when an element comes in existence, bind something to it. In actuality, it’s a computational nightmare because it requires your browser to look for an element whether or not it exists (and in some cases it may never be created). This as well as a handful of other issues that arose from the use of .live (mainly to do with events not reacting properly to e.stopPropagation() and iOS troubles) is what caused the team to stop supporting it past 1.7.
However! It’s not all bad news, we still have the .delegate (or .on for jQuery 1.7+) method which works a hell of a lot better even though it piggy backs off of live, but one of its main advantages is that it forces you to specify a scope for which you’d like to watch for elements …





