3 ms·
But is event delegation such a good idea? Sure, you're not paying the cost of attaching an event to every thumbnail. But then you're going to execute some code
by flaburgan 3y ago
But is event delegation such a good idea? Sure, you're not paying the cost of attaching an event to every thumbnail. But then you're going to execute some code for every single click on the page, even if totally unrelated. Sounds inefficient to me.
- tuukkah 3y agoIf the user clicks on something where nothing should happen, it does not matter if nothing happens 1ms slower. OTOH if something else should happen, that event handler can call event.stopPropagation(). This stops the event from reaching the delegated event handler, so no inefficiency there.