I know the difference between delegate() and on(), but I have a doubt that on() is very popular and faster than delegate() then why jquery is not removing the delegate()
from its library.
live() has drawbacks then it is removed from jQuery-1.9 version
.
Also if we see the performance between on() and delegate() then on()
is much faster than delegate()
.
Then any reason to keep delegate() in jQuery?
This is what a member of the jQuery team wrote in regard to this issue in 2013:
"We haven't deprecated
.bind
or.delegate
, nor have we indicated we're removing them at any point.They're each only one line in the source so size reduction isn't much of a reason to remove them.
We deprecated
.live
because it has lots of confusing issues that we can't fix."
Basically, while delegate()
has been superseded by on()
, there are no future plans to deprecate delegate()
due to the fact it takes up very little space (and doesn't cause any problems).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With