Javascript Event Preview

Date: 2026-04-23

Use Event Capturing ({ capture: true }

By default, listeners use event bubbling (run last). If you set the capture option to true in addEventListener, your handler will execute during the capturing phase, which happens before the target phase and bubbling phase. 

element.addEventListener('click', (e) => {
  console.log('I run first!');
}, { capture: true });

101200cookie-checkJavascript Event Preview