The scroll event fires when an element has been scrolled. Learn addEventListener vs onscroll, scrollTop / scrollLeft, why handlers should be throttled, how it differs from wheel, and five try-it labs.
01
Kind
Instance event
02
Type
Event
03
When
Element was scrolled
04
Handler
onscroll
05
Bubbles?
No
06
Status
Baseline widely available
Fundamentals
Introduction
scroll answers: “Did this element’s scroll position just change?” That covers overflow boxes, custom scroll panes, and (on document / window) the whole page.
Listen on the element that actually scrolls. Because the event does not bubble, a parent will not see a child’s scroll unless you attach the listener to that child.
💡
Beginner tip
MDN notes scroll can fire at a high rate. Keep handlers light, or throttle with setTimeout / requestAnimationFrame. To detect when scrolling finished, use the Element scrollend event.
Concept
Understanding scroll
An instance event that answers: “Did scroll offset change on this element?”
Trigger — user or script scrolled the element (scrollbar, keys, touch, scrollTo, …).
Event type — generic Event; read position from the element.
Does not bubble — attach to the scrolling element.
Not cancelable — you cannot stop scrolling with preventDefault() on scroll.
Baseline Widely available on MDN (since July 2015).
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property:
scroll is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project. Attach listeners to the element that scrolls and keep handlers light.
✓ Baseline · Widely available
Element scroll
Fires when an element’s scroll position changes; does not bubble; throttle high-rate handlers.
FullWidely available
Google ChromeFull support
Yes
Mozilla FirefoxFull support
Yes
Apple SafariFull support
Yes
Microsoft EdgeFull support
Yes
OperaFull support
Yes
Internet ExplorerSupported (legacy)
Yes
scrollBaseline
Bottom line: Listen on the scrolling element, read scrollTop/scrollLeft, and throttle UI work. Use scrollend when you need the stop signal.
Wrap Up
Conclusion
scroll is the standard signal that an element’s scroll offset changed. Attach it to the right target, read scrollTop / scrollLeft, and keep handlers light.
Confuse wheel (intent) with scroll (position change)
Assume preventDefault on scroll can stop scrolling
Overwrite onscroll if you need multiple listeners
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about scroll
Offset changed—listen on the scroller, throttle the work.
5
Core concepts
📱01
On scroll
offset changed
Trigger
📄02
Event
read scrollTop
API
⇄03
No bubble
listen on target
Compare
⚡04
Throttle
setTimeout / rAF
Perf
🎯05
Baseline
since Jul 2015
Status
❓ Frequently Asked Questions
It fires when an element has been scrolled—its scrollTop and/or scrollLeft changed. Listen on the element that actually scrolls (for example a div with overflow), not only on a parent.
No. MDN marks Element scroll as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
A generic Event (not a specialized ScrollEvent). Read scroll position from the element via scrollTop, scrollLeft, and related properties.
No. Element scroll does not bubble, so a parent listener will not see a child’s scroll. Attach the listener to the scrolling element itself.
Scroll can fire at a very high rate. MDN’s examples use setTimeout (or requestAnimationFrame on Document scroll) so expensive work does not run on every single event.
MDN points to the Element scrollend event for detecting when scrolling has completed. Use scroll for continuous updates and scrollend for the final stop.
Did you know?
Turning a mouse wheel fires wheel even if nothing scrolls (for example at the end of a pane). scroll only fires when the scroll offset actually changes.