☀️🧠 Summer of Learning Sale! Join the Lean Web Club today and get 1 month free, plus 30% off for the first three months after that. Click here to join for free now! One of the first things I teach my JavaScript students when learning about events is event delegation. When you have multiple elements that all react to the same type of event, you can listen for that event on a parent element, and filter out elements that aren't the ones you're looking for. It's easier to author, and better for performance (fewer listeners in the browser's memory).
The other day, one of my students asked me…
Not really! I think the React model of "an individual listener on every single interactive element" is bad, but there's not some magic "that's too many" number I can give you. Generally speaking, I think in terms of components or libraries: one event of each type within a specific component. If I'm listening for If other libraries or components also use a Cheers, Want to share this with others or read it later? View it in a browser. |
0 Komentar untuk "[Go Make Things] How many event listeners is too many in JavaScript?"