How Event Bubbling Enables Event Delegation
Event delegation relies on bubbling. Here is how they connect.
How Event Bubbling Enables Event Delegation
Event delegation is built on event bubbling. Here is how they connect.
The Connection
When you click a child element, the event bubbles to the parent. By putting a listener on the parent, you can handle clicks on all children with one listener.
Without Delegation (Many Listeners)
document.querySelectorAll("li").forEach((li) => { li.addEventListener("click", () => console.log(li.textContent)); });
100 list items = 100 listeners. Memory-heavy. New items need new listeners.
With Delegation (One Listener)
document.querySelector("ul").addEventListener("click", (e) => { if (e.target.tagName === "LI") console.log(e.target.textContent); });
1 listener on the parent. Works for existing and new children. Memory-efficient.
Why Bubbling Makes It Possible
The click on <li> bubbles to <ul>. The <ul> listener checks e.target to see which <li> was clicked. Without bubbling, the <ul> listener would never receive the click.
The Takeaway
Event delegation relies on bubbling: a click on a child bubbles to the parent, which checks e.target. One listener handles all children (existing and new). This is memory-efficient and maintenance-friendly. Bubbling is the foundation of delegation.
When a child is clicked, the event bubbles to the parent. A listener on the parent checks e.target to determine which child was clicked. Without bubbling, the parent would never receive the child's click event.
Fewer listeners (memory-efficient), works for dynamically added children (no need to add new listeners), and simpler code (one handler instead of many).
Check e.target: if (e.target.tagName === 'LI') ... or if (e.target.matches('.item')) ... e.target is the element that triggered the event (the actual clicked child).
Yes. Since the listener is on the parent (which already exists), new children's clicks bubble to the same parent listener. No need to add new listeners for new children. This is a key advantage.
No. Event delegation relies on bubbling. Events that do not bubble (like focus, blur, scroll on elements) cannot use traditional delegation. Use capturing phase or alternative approaches for non-bubbling events.
Ready to master React completely?
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.
Master React
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course.

