DrSensor / nusa

incremental runtime that bring both simplicity and power into webdev (buildless, cross-language, data-driven)
MIT License
4 stars 0 forks source link

Centralize all event handler in the ShadowRoot node #22

Closed DrSensor closed 1 year ago

DrSensor commented 1 year ago

📚 Reference hydration requires allocating a memory on startup

Apparently, doing element.addEventListener on every on:<event> attribute will increase the memory consumption compared where you put every logic in window.addEventListener. Instead of listening globally, we can listen all events in the ShadowRoot scope (i.e this.#shadow.addEventListener(/*filter by element and class method*/))