Issue with "Document: scroll event": Example using rAF in scroll-event callbacks is outdated, and anti-performance #12701
Labels
area: DOM/CSSOM
Content:WebAPI
Web API docs
effort: small
This task is a small effort.
help wanted
If you know something about this topic, we would love your help!
MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/Document/scroll_event
What information was incorrect, unhelpful, or incomplete?
The example using requestAnimationFrame in scroll event callbacks is totally outdated, it in fact anti-performance wise in these days.
Firing scroll events is aligned/defined in the HTML spec, all major browsers, Chrome, Safari and Firefox fire before processing requestAnimationFrame callbacks, so with the requestAnimationFrame callacks it just triggers queuing a redundant requestAnimationFrame callback and invoking the callback.
Specific section or headline?
https://developer.mozilla.org/en-US/docs/Web/API/Document/scroll_event#examples
What did you expect to see?
Scroll event handlers can be used without requestAnimationFrame callbacks.
Did you test this? If so, how?
I tested with a simple example having scroll event handler and requestAnimationFrame callbacks something like this;
Thank you, MDN content editors.
MDN Content page report details
en-us/web/api/document/scroll_event
The text was updated successfully, but these errors were encountered: