Skip to content

Lighthouse // Scroll-Listeners needs to be marked as passive #567

@sebastian-marinescu

Description

@sebastian-marinescu

Currently websites using AOS are failing the best-practices section in the Lighthouse-Test, due to the issue "Does not use passive listeners to improve scrolling performance", like described in the docs.

This is:

  • Feature request

Expected Behavior

All scroll-event-listeners are marked as passive listeners.

Possible Solution

Here

aos/src/js/aos.js

Lines 60 to 65 in 329fb34

window.addEventListener(
'scroll',
throttle(() => {
handleScroll($aosElements, options.once);
}, options.throttleDelay)
);
the scroll-listener needs a 3rd parameter, like:

  window.addEventListener(
    'scroll',
    throttle(() => {
      handleScroll($aosElements, options.once);
    }, options.throttleDelay),
    { passive: true }
  );

I'm going to provide a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions