In a web project I'm using multiple listeners for the same window events.
window.addevntlistener("resize", callback)
window.addevntlistener("hasChange", callback)
I assume adding multiple event listeners on the window has a negligible effect in terms of performance. Is it so, or should I just listen once, and add a my own javascript subscribing solution for the various units which need to be notified?
The resize listener could be used by a basic UI element which is rendered in a list, and therefor add hundreds of listeners.
Edit: I'm aware of Does adding too many event listeners affect performance? . However, that refers to a element click events. In that case there are multiple listeners to multiple objects. In my case there are multiple listeners to the same object, and a special object - the window.
from How does multiple listeners for the same window events affect performance?
No comments:
Post a Comment