Nodette saysCustom events let parts of your app communicate via the DOM with CustomEvent and dispatchEvent.
Create your own events: new CustomEvent("cart:add", { detail: data }), then el.dispatchEvent(evt). Anything listening for "cart:add" receives it, reading payload from event.detail. This decouples components — a sender doesn't need a reference to receivers, mirroring a lightweight pub/sub on the DOM.
Power-ups you unlock
new CustomEvent(type, { detail }) carries data
dispatchEvent(evt) fires it
Listeners read event.detail
Decouples components (DOM pub/sub)
The Event Bubbler attacks — common mistakes
Forgetting bubbles:true when delegation is needed
Putting huge objects in detail
Namespacing collisions with built-in event names
Boss battleDispatch a custom "ping" event with detail and handle it elsewhere.