4 ms·
> The method attaches the same event handler to every matched element in the selection. Why is that a con for .bind()? This used to be considered a performanc
by bluesnowmonkey 15y ago
> The method attaches the same event handler to every matched element in the selection.
Why is that a con for .bind()? This used to be considered a performance benefit compared to onclick.
- rimantas 15y agoI think you misread this. It does not bind the same instance of the handler to each element. Each element gets its own copy of this handler, hence the waste of memory.
- spohlenz 15y agoCompared to onclick, it's certainly a performance benefit. However the difference here is in looping over every matched element to add the handler (bind) versus adding the handler to a single element further up the DOM tree (delegate).