In 2017, Chrome, Firefox and Safari added support for passive event listeners. They help to make scrolling work smoother and are enabled by passing {passive: true}
into addEventListener()
.
The explainer mentions that passive: true
works for wheel and touch events. I practically analyzed when passive: true
actually helps:
Event | Works better with passive: true |
Is passive by default |
---|---|---|
wheel ¹ |
Yes (Chrome), No (Firefox) | No (Chrome), No (Firefox) |
touchstart |
Yes (Chrome), ?² (Firefox) | Yes (Chrome), ?² (Firefox) |