.clearQueue() (since jQuery 1.4) removes every function on a queue that has not yet run. Without an argument it clears "fx", the standard effects queue. Returns the jQuery object for chaining.
Remember
$el.clearQueue(); // clear pending fx items
$el.clearQueue("tasks"); // clear a named queue
$el.clearQueue().stop(); // drop waiting + halt current effect
// Waiting list emptied · current effect still runs unless .stop()
Select the element, clear the queue you care about, and call .stop() if the current effect should stop too.
Select the animated element ($("#box")).
Call .clearQueue() (or .clearQueue("name") for a custom queue).
Optionally call .stop() to halt the effect already in progress.
Start a fresh animation only after the waiting list is empty.
Piece
Required?
Role
Matched set
Yes
Elements whose queue you clear
queueName
No
Defaults to "fx"; pass a custom name when needed
Return value
—
jQuery object (chainable)
Pseudocode
Pseudocode
call $(elements).clearQueue(queueName?)
name = queueName or "fx"
for each matched element:
remove every function on queue "name"
that has not started yet
leave the currently running function alone
return the jQuery set for chaining
// Cancel mid-chain (official pattern):
// $el.clearQueue()
// $el.stop()
Reference
Cheat Sheet
Keep these facts handy while managing animation queues.
Topic
Detail
Syntax
.clearQueue( [queueName] )
Since
jQuery 1.4
Default queue
"fx" (effects)
Removes
Pending functions only
Does not
Stop the current animation
Cancel mid-chain
$el.clearQueue().stop()
Named queue
$el.clearQueue("tasks")
Inspect length
$el.queue("fx").length
Rapid clicks
$el.clearQueue().stop().animate(…)
Try it
Live Preview
Start a short animation chain, then Stop to clearQueue + stop. Watch the pending count.
Box
Start queues fade + width + fadeOut. Stop clears pending items and halts the current effect.
Result
Ready — start a chain, then stop mid-way.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
Example 1 — Official Start/Stop Demo
From the jQuery docs: build a long chain, then clear pending steps and stop the current effect.
Both calls leave pending fx length at 0 (or near 0)
clearQueue also targets custom .queue() callbacks on any name
stop(true) is animation-focused on fx
How It Works
Setup. One animate plus a custom queued callback.
stop(true). Clears the fx queue (animation-oriented).
clearQueue. Also clears pending fx items — and works on named queues.
Length..queue("fx").length shows what is still waiting.
Example 3 — Clear a Named Custom Queue
Pass a queue name to clear non-fx work built with .queue("tasks", fn).
jQuery
var $el = $("#worker");
$el.queue("tasks", function (next) { next(); });
$el.queue("tasks", function (next) { next(); });
$el.queue("tasks", function (next) { next(); });
$("#clear").on("click", function () {
var before = $el.queue("tasks").length;
$el.clearQueue("tasks");
var after = $el.queue("tasks").length;
$("#log").text("before: " + before + "\nafter: " + after);
});
pending count: 2 (or similar — one may already be running)
after clearQueue: 0
How It Works
Queue. Three effects are chained onto fx.
Length. Shows how many functions are still waiting.
Clear. Removes pending items (not the one in flight).
After. Pending count drops to 0.
Watch outs
Edge Cases & Pitfalls
Case
What happens
Fix
Only .clearQueue()
Current effect keeps playing
Also call .stop() when canceling
Wrong queue name
Named queue untouched; fx may still grow
Match the name used in .queue("name", …)
Expect jump-to-end
Clearing does not finish styles
Use .stop(true, true) or .finish()
Empty queue
Safe no-op
Still fine to call before a new animation
Custom callback already running
That callback is not removed
Clear before it starts, or design it to exit early
Compatibility
Browser Support
.clearQueue() has been part of jQuery since 1.4. It works in every browser that runs your loaded jQuery version — no separate browser feature flag.
✓ Stable · jQuery 1.4+
jQuery .clearQueue()
Supported across jQuery 1.x (1.4+), 2.x, and 3.x. Prefer a current jQuery 3.x build. Pair with .stop() when canceling live animations.
100%With jQuery
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.clearQueue()Universal
Bottom line: Safe for everyday queue control. Clear pending work, stop the current effect when needed, and use named queues for non-animation tasks.
Analysis
Performance Notes
Approach
Cost
Best for
.clearQueue() on click
Cheap
Cancel buttons, rapid toggles
Long stacked fx queues
Wasted frames
Clear (or stop) before each new effect
Many elements × deep queues
More bookkeeping
Animate fewer elements; clear early
Clearing a queue is inexpensive. The real cost is letting spam clicks build long animation chains — clear (and stop) early so the browser is not painting outdated steps.
Remember
Key Takeaways
Role: remove pending queue functions — since jQuery 1.4.
Default: clears "fx"; pass a name for custom queues.
Cancel:.clearQueue().stop() — drop waiting + halt current.
Scope: works on .queue() callbacks — not only animations.
One line:.clearQueue() empties waiting queue items — pair with .stop() to cancel a live chain.
Frequently Asked Questions
.clearQueue() removes every function on the named queue that has not yet run. It empties the waiting list so chained effects and queued callbacks never start. It does not undo an animation that is already in progress.
An optional string naming which queue to clear. It defaults to "fx" — jQuery’s standard effects queue used by .animate(), .fadeIn(), .slideUp(), and similar methods. Pass a custom name like "tasks" to clear queues built with .queue("tasks", fn).
For the fx queue, both remove pending items. .stop(true) is animation-focused and can also jump the current effect to its end when combined with jumpToEnd. .clearQueue() is queue-generic — it removes any pending function added via .queue(), not only animation steps.
No. Only functions that have not started are removed. The effect currently executing continues until it finishes or you call .stop(). The official jQuery demo calls both .clearQueue() and .stop() on Stop for that reason.
Yes. That is a key difference from .stop(). When you queue a non-animation callback with .queue(fn), .clearQueue() removes pending ones. .stop() is meant for animations, not arbitrary queued work.
Often yes when canceling mid-animation: .clearQueue() drops everything waiting; .stop() halts the effect currently playing. For a rapid-click guard before a new animation, .clearQueue().stop() (or .stop(true)) is a common pattern.