Skip to content

Is passive: true necessary in scroll listeners? #2023

Closed Answered by Grenish
rebelmusic asked this question in Q&A
Discussion options

You must be logged in to vote

@rebelmusic Hi there! Thank you for raising this issue. The use of { passive: true } in a scroll event listener is related to optimizing browser performance. It indicates that the listener won't prevent default scrolling behavior.
If your code inside the listener doesn't include actions that prevent default behavior, like event.preventDefault(), then using { passive: true } might be unnecessary. Browsers may interpret it differently, and testing in your specific context will help decide if it's beneficial.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Chalarangelo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
js Related to JavaScript content.
3 participants
Converted from issue

This discussion was converted from issue #1964 on September 27, 2023 17:08.