Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule to ensure scrolling event handlers are passively bound #93

Open
stramel opened this issue May 10, 2021 · 0 comments
Open

Add rule to ensure scrolling event handlers are passively bound #93

stramel opened this issue May 10, 2021 · 0 comments

Comments

@stramel
Copy link
Contributor

stramel commented May 10, 2021

This is a perf enhancement suggested by lighthouse.

When wheel, touchstart, mousewheel, touchmove, orscroll are bound in the template, they should utilize the passive: true property.

To achieve this, you could:

  • Use the decorator @eventOptions({passive: true})
  • Bind using the event syntax, <div @scroll=${{ handleEvent: handleScroll, passive: true }}>

Tricky things to note, these 2 cases should pass:

  • passive: false explicitly set to false.
  • when the event handler uses e.preventDefault(); it should be fine to bind without passive.

https://web.dev/uses-passive-event-listeners/
https://github.com/GoogleChrome/lighthouse/blob/75735c6b2a2c13f0b92a0b9d00067235ffa21fcc/lighthouse-cli/test/fixtures/dobetterweb/dbw_tester.html#L273

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant