clearwater icon indicating copy to clipboard operation
clearwater copied to clipboard

Delegate DOM events?

Open jgaskins opened this issue 7 years ago • 0 comments

We currently place DOM event handlers on the elements' on#{whatever} properties. I've heard that this is considered a poor practice, performance-wise. I haven't found any hard data to back that up and my own performance tests show no meaningful difference.

I tested it by adding dom-delegator and updating on#{event_name} in the properties hash translation to become ev-#{event_name}. The app worked exactly as it had, and event handler usage became constant (instead of increasing until the previous handlers were GCed as with setting onclick), but CPU time and memory usage did not change by any meaningful amount across several test runs both before and after.

What I'm wondering is, is there any real-world benchmarks for recent browsers showing that using event delegation is truly more efficient?

jgaskins avatar Jan 14 '18 00:01 jgaskins