passive event listener

An event listener registered with { passive: true }, which promises never to call preventDefault, so the browser can scroll immediately without waiting for it.

In more detail

For touch and wheel events the browser must normally wait to see whether the listener cancels the scroll. A passive listener removes that wait; calling preventDefault inside one is ignored and logs a warning. Browsers make touch and wheel listeners on window, document and body passive by default.

Example

el.addEventListener('touchstart', onTouch, { passive: true })

Related terms

Taught in

References