Lighthouse: "Uses passive event listeners to improve scrolling performance" documentation needs updating

Created on 25 Aug 2017  Â·  13Comments  Â·  Source: GoogleChrome/lighthouse

On the Uses Passive Event Listeners to Improve Scrolling Performance page it states that the implementation "Filter[s] out listeners that call preventDefault()".

This doesn’t seem to work properly as the following listener makes it into the report when Lighthouse reports a failed Uses passive listeners to improve scrolling performance.

```
document.addEventListener('wheel', function(event) {
event.preventDefault();
})
````

I expected the case to pass since all wheel event listeners in my code call preventDefault. Maybe I missed something here.

  • Google Chrome version 60.0.3112.101
  • Lighthouse version 2.3.0
P2 docs

Most helpful comment

Ya I agree we shouldn't warn; 770208 opened

All 13 comments

Ah thanks for the report @kleinfreund the description is out of date (cc: @kaycebasques). This audit is now backed by Chrome's built-in performance violations which flags the use of these listeners in any case, not just ones that could be marked as passive without any code change.

This was also just raised here: https://bugs.chromium.org/p/chromium/issues/detail?id=489802#c42

I think its fairly reasonable for us to not warn you if you set {passive:false}. We will still need a documentation change in this case.

But we'll also need a chrome-side change.

@dtapuska - do you think we should warn on use of passive:false?

Ya I agree we shouldn't warn; 770208 opened

I can also see this error when using Polymer components, like in this demo.

Yes that is because polymer by default doesn't use passive touch events. You need to enable passiveTouchGestures setting in polymer.

Thanks!
Is this available in Polymer 2? I tried to add it in this way in the index.html:

    <link rel="import" href="/polymer/node_modules/@npm-polymer/polymer/polymer.html">
    <script>
        Polymer.setPassiveTouchGestures(true);
    </script>

but I get:

Uncaught TypeError: Polymer.setPassiveTouchGestures is not a function

Thanks, it says to

move the script down below the Polymer import.

which is what I am doing, but I still see the error, do you know of a complete working sample using it?

Are you using version 2.1.0 or later?

I am using 2.0.1

I think this can be closed, right?

Yes. If you set {passive:false} you will not get a console violation nor will Lighthouse flag it.

Was this page helpful?
0 / 5 - 0 ratings