{"data":{"slug":"github-thedaviddias-front-end-checklist-skills-event-delegation-63238cec85fd","title":"Optimize Dynamic Content with Event Delegation","summary":"Use event delegation to reduce memory usage and improve performance for dynamic content in JavaScript applications by attaching a single event listener to a parent element instead of multiple listeners on individual child elements.","url":"https:\/\/skillshunter.net\/skills\/github-thedaviddias-front-end-checklist-skills-event-delegation-63238cec85fd","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-thedaviddias-front-end-checklist-skills-event-delegation-63238cec85fd","markdown_url":"https:\/\/skillshunter.net\/skills\/github-thedaviddias-front-end-checklist-skills-event-delegation-63238cec85fd.md","download_url":"https:\/\/skillshunter.net\/skills\/github-thedaviddias-front-end-checklist-skills-event-delegation-63238cec85fd\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Ensure the parent container is properly scoped and that event.target.closest() is used to identify the intended target element. Clean up listeners on the parent when the container is removed from the DOM.","instructions":"---\nname: event-delegation\ndescription: \"Use when reviewing scripts, client components, bundles, or runtime behavior related to Use event delegation for dynamic content. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.\"\nmetadata:\n  category: javascript\n  priority: medium\n  difficulty: intermediate\n  estimatedTime: \"15\"\n  source: frontendchecklist.io\n  url: https:\/\/frontendchecklist.io\/rules\/javascript\/event-delegation\n---\n\n# Use event delegation for dynamic content\n\nAdding hundreds of individual event listeners for list items or table rows consumes significant memory and creates performance overhead. Dynamic content (items loaded via AJAX or rendered after user actions) won't have event listeners unless you re-attach them after each update \u2014 event delegation solves both problems at once.\n\n## Quick Reference\n\n- Attach one listener to a parent instead of many to individual children\n- Use event.target.closest() to identify the intended target element\n- Event delegation automatically works for elements added dynamically\n- Clean up listeners on the parent when the container is removed\n\n## Check\n\nFind any code in this file that attaches the same event handler to multiple elements in a loop. Suggest event delegation as an alternative.\n\n## Fix\n\nRefactor these per-element event listeners to use event delegation on the common parent container.\n\n## Explain\n\nExplain event delegation, how event bubbling enables it, and when to use closest() vs target.\n\n## Code Review\n\nReview scripts, client components, and browser execution paths related to Use event delegation for dynamic content. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.\n\n---\n\nFor full implementation details, code examples, and framework-specific guidance,\nsee `references\/rule.md`.\n\nRule page: https:\/\/frontendchecklist.io\/rules\/javascript\/event-delegation\n","use_cases":["Reducing memory consumption when handling multiple event listeners for dynamic elements.","Improving performance for dynamically loaded content such as AJAX or rendered table rows.","Avoiding the need to re-attach event listeners after DOM updates."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/thedaviddias\/Front-End-Checklist\/blob\/e8d14d049010e2ce25afcd5e8609dfcbbe63e47e\/skills\/event-delegation\/SKILL.md","source_commit":"e8d14d049010e2ce25afcd5e8609dfcbbe63e47e","license":null,"version":null,"listing_approved_at":"2026-11-23","created_at":"2026-11-22T16:03:33.000000Z","updated_at":"2026-11-23T04:55:08.000000Z","seo_title":"Optimize Dynamic Content with Event Delegation","seo_description":"Learn how to use event delegation for dynamic content to improve performance and reduce memory usage in JavaScript applications.","seo_keywords":["event delegation optimization","dynamic content performance","JavaScript event handling","reduce memory usage","improve DOM performance"]}}