Passive Event Listeners & Scroll Jank

Real wheel and touchmove listeners on the race programme: passive or not, preventDefault, heavy work; cancelable, defaultPrevented and the passive default on…

Why it matters

One heavy touchmove listener that is not passive is enough to make scrolling on a phone stutter: every touch waits for your JavaScript. The other way round, preventDefault() in a passive listener is quietly ignored, and a listener on window or body is already passive by default.

The key idea

passive is a promise: "I will not cancel"

Common mistakes

Try it in this playground