JavaScript Document scrollend Event

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Document event
Baseline 2025

What You’ll Learn

The Document scrollend event fires when the document view has finished scrolling. Learn how it differs from scroll, when gestures count as complete, how to use onscrollend, and five try-it labs.

01

Kind

Document event

02

Type

Event

03

Means

Scrolling finished

04

vs scroll

Settled, not continuous

05

Handler

onscrollend

06

Status

Baseline 2025

Introduction

scroll is noisy—it fires many times while the page moves. scrollend answers a different question: has scrolling completed?

Per MDN, scrolling is complete when there are no more pending scroll-position updates and the user has finished their gesture. That is the right moment for snap follow-up, lazy cleanup, or analytics that should not run on every pixel of movement.

💡
Beginner tip

Touch panning and trackpad scrolling are not “done” until pointers or keys are released (MDN). If the scroll position never changed, scrollend does not fire.

Understanding Document scrollend

A Document event that answers: “Did the document view finish scrolling?”

  • Fires when the document view has completed scrolling (MDN).
  • Complete means no pending scroll updates + gesture finished.
  • Includes wheel, keyboard, scroll-snap, APIs, and other gestures that update scroll position.
  • Event type — a generic Event.
  • Handlerdocument.onscrollend or addEventListener("scrollend", ...).
  • Status — Baseline 2025 Newly available (since December 2025 on MDN).

📝 Syntax

Use the event name with addEventListener, or set the handler property:

JavaScript
addEventListener("scrollend", (event) => { });

onscrollend = (event) => { };

Event type

A generic Event.

MDN-style pairing with scroll

JavaScript
const output = document.querySelector("#output");

document.addEventListener("scroll", () => {
  output.textContent = "Document scroll event fired!";
});

document.addEventListener("scrollend", () => {
  output.textContent = "Document scrollend event fired!";
});

⚡ When Is Scrolling “Complete”?

  • Pending updates done — smooth or instant wheel/keyboard/snap/API scroll finished updating position.
  • Gesture finished — touch/trackpad fingers or keys released (MDN).
  • No movement — if position did not change, no scrollend.
  • Element overflow — use Element scrollend, not Document.

⚖️ scrollend vs scroll

Topicscrollscrollend
MeaningView is moving / movedScrolling has finished
How oftenMany times during motionOnce per completed scroll
Best forLive progress UI (throttled)Idle work, snap follow-up
MDN BaselineWidely available (2015)Baseline 2025 (Dec 2025)
Handler propertyonscrollonscrollend

⚡ Quick Reference

GoalCode / note
Listendocument.addEventListener("scrollend", fn)
Handler propertydocument.onscrollend = fn
Final positionRead window.scrollY in the handler
Feature-detect"onscrollend" in document (or try/add listener carefully)
Sibling continuous eventscroll
MDN statusBaseline 2025 Newly available (Dec 2025)

🔍 At a Glance

Four facts to remember about Document scrollend.

Event type
Event

Plain Event

Means
Settled

Scroll finished

Not for
Every tick

Use scroll for that

Status
B2025

Newly available

Examples Gallery

Examples follow MDN Document: scrollend event. Labs use tall pages—scroll, then stop, to see scrollend. Feature-detect on older browsers.

📚 Getting Started

MDN patterns for addEventListener and onscrollend.

Example 1 — scroll + scrollend Listener (MDN)

Show which event fired last while you scroll and then stop.

JavaScript
const output = document.querySelector("#output");

document.addEventListener("scroll", () => {
  output.textContent = "Document scroll event fired!";
});

document.addEventListener("scrollend", () => {
  output.textContent = "Document scrollend event fired!";
});
Try It Yourself

How It Works

During motion you mostly see scroll. When updates settle and the gesture ends, scrollend replaces the message—MDN’s teaching demo.

Example 2 — document.onscrollend

Same idea using handler properties (MDN).

JavaScript
const output = document.querySelector("#output");

document.onscroll = () => {
  output.textContent = "Document scroll event fired!";
};

document.onscrollend = () => {
  output.textContent = "Document scrollend event fired!";
};
Try It Yourself

How It Works

Prefer addEventListener when multiple modules need the event. The property form matches MDN’s second sample.

📈 Detect, Position & Idle UI

Feature-detect Baseline 2025 support and run settled-scroll work.

Example 3 — Feature Detect scrollend

Fall back to a throttled scroll idle timer when scrollend is missing.

JavaScript
const out = document.getElementById("out");

function onSettled() {
  out.textContent = "Scrolling settled @ Y=" + Math.round(window.scrollY);
}

if ("onscrollend" in document) {
  out.textContent = "scrollend supported — scroll then stop";
  document.addEventListener("scrollend", onSettled);
} else {
  out.textContent = "No scrollend — using scroll idle fallback";
  let t;
  document.addEventListener("scroll", () => {
    clearTimeout(t);
    t = setTimeout(onSettled, 150);
  }, { passive: true });
}
Try It Yourself

How It Works

Baseline 2025 is new. Older browsers need a fallback. A short idle timer on scroll is an approximate substitute—not identical to the native event.

Example 4 — Log Final scrollY

Read the settled position only when scrolling ends.

JavaScript
const out = document.getElementById("out");

document.addEventListener("scrollend", () => {
  out.textContent =
    "Final position: Y=" + Math.round(window.scrollY) +
    " X=" + Math.round(window.scrollX);
});
Try It Yourself

How It Works

Perfect for “where did the user land?” without sampling every scroll tick. Pair with scrollingElement if you prefer scrollTop.

Example 5 — Idle Badge After Scroll Ends

Show “scrolling…” on scroll, then “idle” on scrollend.

JavaScript
const badge = document.getElementById("badge");

document.addEventListener("scroll", () => {
  badge.textContent = "scrolling…";
  badge.dataset.state = "busy";
}, { passive: true });

document.addEventListener("scrollend", () => {
  badge.textContent = "idle";
  badge.dataset.state = "idle";
});
Try It Yourself

How It Works

A clear mental model for beginners: scroll = busy, scrollend = idle. Use that split for expensive work that should wait until motion stops.

🚀 Common Use Cases

  • Running cleanup or analytics only after the user stops scrolling.
  • Updating UI after scroll-snap settles.
  • Recording the final scrollY for “resume reading” features.
  • Pausing expensive effects while scroll is busy, restarting on scrollend.
  • Teaching the difference between continuous and settled scroll events.

🔧 How It Works

1

User scrolls the page

Wheel, keyboard, touch, trackpad, snap, or scrollTo updates position.

Motion
2

scroll fires (often)

Continuous updates while the view moves.

Busy
3

Updates + gesture finish

No pending position updates; pointers/keys released when required.

Settle
4

scrollend fires

Safe moment for idle work (if position actually changed).

📝 Notes

  • MDN: Baseline 2025 Newly available (since December 2025)—no Deprecated / Experimental / Non-standard banner.
  • Feature-detect for older browsers; offer a scroll-idle fallback if needed.
  • No event if scroll position did not change (MDN).
  • Element overflow uses Element scrollend.
  • Related learning: scroll, scrollingElement, JavaScript hub.

Browser Support

Document scrollend is marked Baseline 2025 on MDN (newly available since December 2025). Logos use the shared browser-image-sprite.png sprite from this project. Older browsers may lack support—feature-detect and provide a fallback.

Baseline 2025

Document scrollend

Fires when the document view has completed scrolling (settled position + finished gesture).

B2025 Newly available
Google Chrome Supported in current versions (check BCD)
Supported
Mozilla Firefox Supported in current versions (check BCD)
Supported
Apple Safari Supported in current versions (check BCD)
Supported
Microsoft Edge Chromium · Baseline 2025 path
Supported
Opera Follow Chromium behavior
Supported
Internet Explorer No scrollend
Not supported
scrollend Baseline 2025

Bottom line: Use scrollend for settled-scroll work. Pair with scroll for live UI. Feature-detect onscrollend and fall back on older engines.

Conclusion

scrollend is the settled-scroll signal for the document view. Use scroll for live feedback (throttled), and scrollend when work should wait until motion and gestures finish. Feature-detect for pre–Baseline 2025 browsers.

Continue with scrollsnapchange, scrollingElement, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use scrollend for work after scrolling settles
  • Feature-detect ("onscrollend" in document)
  • Pair with scroll when you need live status
  • Read final window.scrollY in the handler
  • Use Element scrollend for overflow boxes

❌ Don’t

  • Expect scrollend on every scroll tick
  • Assume older browsers support it without a check
  • Expect an event when position never changed
  • Listen on Document for a nested scrollable div
  • Treat it as Experimental—MDN marks Baseline 2025

Key Takeaways

Knowledge Unlocked

Five things to remember about Document scrollend

Scrolling finished — settled updates + completed gesture.

5
Core concepts
🔄 02

vs scroll

not every tick

Compare
👋 03

Gesture

until release

MDN
🔍 04

Detect

onscrollend in

Compat
05

Baseline

2025 newly

Status

❓ Frequently Asked Questions

It fires when the document view has completed scrolling — when there are no more pending scroll position updates and the user has finished their gesture (MDN).
No. MDN marks Document scrollend as Baseline 2025 (newly available since December 2025). It is not Deprecated, Experimental, or Non-standard. Older browsers may still lack support, so feature-detect.
scroll fires continuously while the view moves. scrollend fires once when scrolling has settled. Prefer scrollend for idle cleanup, snap follow-up, or analytics that should not run on every tick.
MDN: if the scroll position did not change, no scrollend event fires. Also, touch/trackpad gestures are not complete until pointers or keys are released.
Yes. You can use document.onscrollend or document.addEventListener("scrollend", ...).
Use the Element scrollend event on that overflow element. Document scrollend is for the document view (page scroll).
Did you know?

Before scrollend, developers often faked “scroll stopped” with a debounced timer on scroll. The native event is more accurate for gestures and smooth scrolling—but a timer fallback is still useful on older browsers.

Next: Document scrollsnapchange

Learn the Document event that fires when a new CSS scroll snap target is selected.

scrollsnapchange →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful