I searched for topics on increasing productivity using the delegation mechanism. I am talking about simple javascript, without jQuery or other tools / libraries.
Each element generates events in the DOM tree, and they move through it using the bubble mechanism.
Delegation works by avoiding creating an event handler for each element, but by capturing more events in one handler. In addition, by stopping bubbling, the handler can avoid the event for further distribution if it is already correctly processed. Thus, this will reduce the consumption of resources on the page.
But if the bubbles do not stop, events appear and propagate through the entire DOM tree, so the page uses the same resource consumption, using delegation or not. And, if a delegated handler needs to do an event source check, it will also be more consuming ...
So, where is the performance gain when using delegation, besides simple programming, simple and clean programming?
Is there a way to avoid certain events for generating in general or certain elements in order to generally generate certain events, thereby significantly saving when using resources? For example, plain text on the mouse generates many useless messages on a regular page; if this message should not be processed, can it be prevented at the source?
source
share