JavaScript Window stop() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Method

Definition

window.stop() stops further resource loading in the current browsing context — equivalent to the browser’s Stop button (MDN). No parameters; returns undefined.

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call window.stop. Start with this line.

JavaScript
stop() / window.stop()
CallWhat it does
stop() / window.stop()Primary signature.
window.stop(...)Call with the arguments your case needs.

Built into the browser. Call window.stop(...) (or the global stop(...)) — no import required.

Library declarations
JavaScript
stop() / window.stop()

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*Always undefined

JavaScript Examples

Example 1 — Basic Call

MDN: call window.stop() with no arguments.

JavaScript
window.stop();
// same as: stop();
console.log("stop() called");
Try It Yourself

How It Works

  1. Call. No parameters.
  2. Effect. Browser stops further resource loading.
  3. Return. Always undefined.
  4. Timing. Most useful while loads are still pending.

Example 2 — User Cancel Button

Let the user stop pending image downloads.

JavaScript
document.getElementById("stopBtn").onclick = function () {
  window.stop();
  document.getElementById("status").textContent =
    "Loading stopped by user.";
};
Try It Yourself

How It Works

  1. User gesture. Click triggers stop().
  2. Halt loads. Pending images/resources can stop.
  3. Feedback. Update status so the user knows why.
  4. UX tip. Prefer an explicit Cancel over silent auto-stop.

Example 3 — Check readyState First

Decide whether stopping still makes sense.

JavaScript
const state = document.readyState;
window.stop();
console.log("readyState was:", state);
console.log("readyState now:", document.readyState);
Try It Yourself

How It Works

  1. Read state. "loading" / "interactive" / "complete".
  2. Call stop. Ask the browser to halt further loads.
  3. Compare. On a finished page, state often stays complete.
  4. Related. See document.readyState.

Example 4 — Timed Stop Policy

Pair with setTimeout for a “give up after N ms” rule.

JavaScript
const timer = setTimeout(function () {
  window.stop();
  console.log("Stopped after timeout");
}, 5000);

// optional: clearTimeout(timer) if load finishes earlier
Try It Yourself

How It Works

  1. Schedule. Wait 5 seconds with setTimeout.
  2. Stop. Call window.stop() if still waiting.
  3. Explain. Tell the user the page was cut short.
  4. Clear. Cancel the timer if load finishes early.

Example 5 — Not for Media or fetch

Pick the right API: loading vs playback vs network cancel.

JavaScript
// Document loading (Stop button):
window.stop();

// Media playback — different API:
// video.pause();

// Cancel fetch — different API:
// controller.abort();
Try It Yourself

How It Works

  1. stop(). Browser resource loading in this context.
  2. pause(). Media element playback only.
  3. abort(). Cancel a specific network request.
  4. Choose. Match the API to the problem.

Browser Support

Window.stop() is marked Baseline Widely available on MDN (since August 2016). It is not Deprecated, Experimental, or Non-standard. Browser Window API — not a Node.js built-in.

✓ Baseline · Widely available

stop()

Stop further resource loading like the browser Stop button.

99% Core tag support
Chrome Yes
Full support
Edge Yes
Full support
Firefox Yes
Full support
Safari Yes
Full support
Opera Yes
Full support
HTML element 100% supported

Bottom line: Universal API. Most useful while resources are still downloading; pair with clear UX feedback.

Frequently Asked Questions

It stops further resource loading in the current browsing context — equivalent to the browser’s Stop button (MDN). Content already shown usually stays; pending images and similar loads can be halted.
No. MDN marks Window.stop() as Baseline Widely available (since August 2016). It is not Deprecated, Experimental, or Non-standard.
No parameters. Call stop() with empty parentheses. The return value is undefined.
MDN: because of how scripts run, stop() cannot interrupt its parent document’s loading, but it can stop images, new windows, and other still-loading objects.
No. stop() is for document resource loading. To pause media, use element.pause(). To cancel fetch(), use AbortController.
While a page is still loading — for example a Cancel button for slow images or a navigation the user wants to abort. After load finishes, it usually has little effect on later fetch() calls.

Next: Interview programs

Practice JavaScript interview questions and patterns.

Interview →

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.

8 people found this page helpful