Skip to content

Window scroll listener causes scroll stuttering in Chrome #136

@pieh

Description

@pieh

This is cross-posted issue from gatsbyjs/gatsby#12520

Description

In Chrome DevTools using the FPS meter, the scroll listener that Gatsby seems to add causes poor scrolling performance. I noticed this on my website and on React's website. I don't add a scroll listener anywhere so I guess it's coming from Gatsby.

Steps to reproduce

  1. Visit atomiks.github.io/tippyjs
  2. Open FPS Meter in Chrome DevTools
  3. For me it's showing ~45 - 55 FPs with lots of frame drops and stuttering
  4. Type this into the console
getEventListeners(window).scroll.forEach(({ listener }) => {
  window.removeEventListener('scroll', listener)
})
  1. Much improved scrolling, way less frame drops once the listener has been removed.

Before: gyazo.com/57edc6fb31e1e06725f7e31c3b2a51a0
After: gyazo.com/3b4070170309a1c0037272a3cb3d3d17

I don't have any context on internals of scroll-behavior package, but maybe adding some debounce to listener function could help?

/cc @atomiks

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