JavaScript Event stopImmediatePropagation() Method

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline Widely available
Instance method

What You’ll Learn

The stopImmediatePropagation() method prevents other listeners of the same event from being called—including remaining listeners on the same element and listeners on other elements later in the path. Learn how it differs from stopPropagation(), why listener order matters, and when to use it—with five examples and try-it labs.

01

Kind

Instance method

02

Returns

undefined

03

Params

None

04

Stops

Same + others

05

vs

stopPropagation

06

Status

Baseline widely

Introduction

One element can have many listeners for the same event type. They run in the order they were added. Sometimes the first handler must win completely: no later handler on that button, and no parent handler either.

That is event.stopImmediatePropagation(). It is stronger than stopPropagation(), which still lets other listeners on the same element finish. Neither method cancels the browser default— use preventDefault() for that.

💡
Beginner tip

Think of stopImmediatePropagation() as “stop everyone else for this event” and stopPropagation() as “finish this element, then stop traveling.”

Understanding Event.stopImmediatePropagation()

An instance method that prevents other listeners of the same event from being called.

  • No parameters — call event.stopImmediatePropagation().
  • Return value — none (undefined).
  • Same element — remaining listeners for this type on the current target are skipped.
  • Other elements — listeners later on the path (for example parents) are also skipped.
  • Order matters — listeners already run before the call are not undone.
  • Baseline Widely available on MDN (since July 2015); also in Web Workers.

📝 Syntax

JavaScript
stopImmediatePropagation()

Parameters

None.

Return value

None (undefined).

Typical pattern

JavaScript
button.addEventListener("click", (event) => {
  if (!allowed) {
    event.stopImmediatePropagation();
    return;
  }
  // Only runs when allowed — later click listeners on button are skipped if stopped
});

⚡ Quick Reference

GoalCode / note
Hard stopevent.stopImmediatePropagation()
Soft stop (same element OK)event.stopPropagation()
Cancel defaultevent.preventDefault()
Register earlyAdd your gate listener first so it can stop others
MDN statusBaseline Widely available (since July 2015)

🔍 At a Glance

Four facts to remember about stopImmediatePropagation().

Stops
listeners

Same + later

Order
matters

Add first

Default
unchanged

Use preventDefault

Baseline
widely

Since Jul 2015

Examples Gallery

Examples follow MDN Event: stopImmediatePropagation(). Use View Output or Try It Yourself.

📚 Getting Started

See remaining same-element listeners get skipped.

Example 1 — Skip Later Listeners on the Same Button

Handler 1 stops; handlers 2 and 3 never run.

JavaScript
btn.addEventListener("click", (e) => {
  out.textContent += "1\n";
  e.stopImmediatePropagation();
});
btn.addEventListener("click", () => { out.textContent += "2\n"; });
btn.addEventListener("click", () => { out.textContent += "3\n"; });
// Click → only "1"
Try It Yourself

How It Works

Immediate stop cuts the queue of remaining listeners on that target.

Example 2 — stopPropagation Still Runs Same-Element Listeners

Contrast: soft stop lets handlers 2 and 3 on the button finish.

JavaScript
btn.addEventListener("click", (e) => {
  out.textContent += "1\n";
  e.stopPropagation(); // not immediate
});
btn.addEventListener("click", () => { out.textContent += "2\n"; });
btn.addEventListener("click", () => { out.textContent += "3\n"; });
// Click → "1", "2", "3" (parent still skipped)
Try It Yourself

How It Works

This is the key MDN distinction between the two stop methods.

📈 Path & Order

Parents, registration order, and a three-way comparison.

Example 3 — Parent Listener Is Skipped Too

Immediate stop also prevents bubbling to a parent handler.

JavaScript
child.addEventListener("click", (e) => {
  out.textContent += "child\n";
  e.stopImmediatePropagation();
});
parent.addEventListener("click", () => {
  out.textContent += "parent\n"; // never for this click
});
Try It Yourself

How It Works

Like stopPropagation for parents—plus it also cuts remaining child listeners.

Example 4 — Registration Order Matters

A late gate cannot stop an earlier listener that already ran.

JavaScript
btn.addEventListener("click", () => { out.textContent += "early\n"; });
btn.addEventListener("click", (e) => {
  out.textContent += "gate\n";
  e.stopImmediatePropagation();
});
btn.addEventListener("click", () => { out.textContent += "late\n"; });
// Click → early, gate  (late skipped; early already ran)
Try It Yourself

How It Works

Register critical gates first if they must block everything else on that target.

Example 5 — Allow / stopPropagation / stopImmediate (MDN Idea)

Three buttons: normal bubble, soft stop, immediate stop.

JavaScript
// allow: all button handlers + parent run
// stopPropagation: all button handlers run; parent skipped
// stopImmediatePropagation: only first button handler; parent skipped
Try It Yourself

How It Works

Matches MDN’s nested-div demo: immediate stop is the strongest listener cutoff.

🚀 Common Use Cases

  • A validation or auth gate that must override other click handlers on the same control.
  • Third-party widgets where multiple libraries attach to one element.
  • Debugging “why did two handlers fire?” by temporarily hard-stopping.
  • Teaching the difference between stopPropagation and stopImmediatePropagation.
  • Ensuring a once-only critical handler is the last thing that runs for that event on the target.

🔧 How It Works

1

Listeners queue

Same-type listeners on the current target are ordered by add time.

Queue
2

One calls stopImmediate

Remaining listeners on this element are marked not to run.

Cut
3

Path stops

Further targets on the event path also do not receive the event.

Path
4

Default separate

Browser default still needs preventDefault if you want it canceled.

📝 Notes

Universal Browser Support

Event.stopImmediatePropagation() is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project. It is also available in Web Workers.

Baseline · Widely available

Event.stopImmediatePropagation()

Prevents other listeners of the same event from being called (same element and further path).

Universal Widely available
Google Chrome Full support · Desktop & Mobile
Full support
Mozilla Firefox Full support · Desktop & Mobile
Full support
Apple Safari Full support · macOS & iOS
Full support
Microsoft Edge Full support · Chromium
Full support
Opera Full support · Modern versions
Full support
Internet Explorer Supported in IE9+ (prefer modern browsers)
Legacy
Event.stopImmediatePropagation() Excellent

Bottom line: Use stopImmediatePropagation when same-element listeners must also be skipped; otherwise prefer stopPropagation.

Conclusion

Event.stopImmediatePropagation() is the strong stop: no more listeners on the current element, and no further travel on the path. Use it sparingly when a gate must win completely; reach for stopPropagation() or preventDefault() when those fit better.

Continue with stopPropagation(), preventDefault(), eventPhase, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Register gate listeners first when they must block others
  • Prefer stopPropagation if same-element handlers should still run
  • Pair with preventDefault when you also need to cancel defaults
  • Document why a hard stop exists in shared codebases
  • Test with multiple listeners on the same node

❌ Don’t

  • Use it as a default for every click handler
  • Expect it to undo listeners that already ran
  • Confuse it with preventDefault
  • Assume capture-phase listeners later in the path will still hear it
  • Rely on it to fix poorly ordered library handlers forever

Key Takeaways

Knowledge Unlocked

Five things to remember about stopImmediatePropagation()

The strong stop for remaining listeners.

5
Core concepts
🔁02

Same el

remaining skipped

Local
📈03

vs stop

stronger cutoff

Compare
📚04

Order

add time wins

Queue
🎯05

Baseline

since Jul 2015

Status

❓ Frequently Asked Questions

It prevents any other listeners for the same event from running—both remaining listeners on the current element and listeners on any other elements that would run later in the event path.
No. MDN marks Event.stopImmediatePropagation() as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. It is also available in Web Workers.
stopPropagation() stops the event from reaching other elements, but other listeners already registered on the same element still run. stopImmediatePropagation() also skips those remaining same-element listeners.
Yes. Listeners on the same element for the same type run in the order they were added. Only listeners after the one that calls stopImmediatePropagation() are skipped on that element.
No. It only affects which listeners run. Use preventDefault() to cancel the browser default (when the event is cancelable).
When you must guarantee no later handler on the same target runs—for example a security/validation gate that must win over other click handlers on the same button.
Did you know?

MDN’s nested-div demo shows the practical difference clearly: with stopPropagation() you still see every handler on the button; with stopImmediatePropagation() you only see handlers up to (and including) the one that called it.

Next: stopPropagation()

Stop further path travel while same-element listeners still run.

stopPropagation() →

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