Reputation: 74420
In the case of a game where user have to click/use keys mutli and many times,
Is there any advantage to use event.stopPropagation() in all event handler which i know bubbling is useless?
Suppose i have a div with a click event binded,
<div id="mydiv">CLICK</div>
$('#mydiv').click(function(){...});
if i click on it, this event will propagate to all ancestors elements of this div (e.g body/html/document/window). So just wondering if this could be better or same or worst to stop immediatly propagation of event.
In fact, i don't know how javascript engine internally deal with events binded (or not) to elements, if this works as a listener or what...
Upvotes: 0
Views: 456
Reputation: 13273
It is a bit general, but to answer your direct question, unless you need to stop propagation then there is no reason to do so. Propagation is not what is going to hinder the efficiency of your game, it's having too many event bindings. Consider using a generic binding on a parent element and then processing the actual target of the event to determine what action to take.
Upvotes: 2