.queue() (since jQuery 1.2) shows, adds to, or replaces the function queue on matched elements. The default queue name is "fx" — the effects pipeline used by .animate(), .fadeIn(), and similar methods.
Pick the overload you need: read, add, or replace — then keep the pipeline moving with next().
Chain effects on an element (they land on the fx queue).
Read with .queue() / .queue("fx") to get the pending Array.
Add a custom step with .queue(function (next) { … next(); }).
Or replace pending work with .queue("fx", []).
For named queues (not fx), call .dequeue("name") to start.
Piece
Required?
Role
queueName
No
Defaults to "fx"
callback
For add
Function to append; gets next since 1.4
newQueue
For replace
Array of functions (use [] to empty)
Return (read)
—
Array of pending functions
Return (add/replace)
—
jQuery object (chainable)
Pseudocode
Pseudocode
queueName = queueName or "fx"
// Read
return array of pending functions on that queue
// Add callback
append callback to the end of the queue
when it runs:
do work
must call next() or .dequeue(queueName)
otherwise later steps never start
// Replace
set queue contents = newQueue array
([] → no pending steps left)
return jQuery set (add/replace) or Array (read)
Reference
Cheat Sheet
Keep these facts handy while building effect chains.
Topic
Detail
Read
.queue([name]) → Array
Add
.queue([name], fn) → jQuery
Replace
.queue([name], array) → jQuery
Since
jQuery 1.2 (next arg since 1.4)
Default name
"fx"
Keep moving
next() or .dequeue()
Empty pending
.queue("fx", []) · .clearQueue()
Named queues
Must .dequeue("name") to start
Try it
Live Preview
Start a short chain and watch .queue("fx").length change. Clear with [] anytime.
Box
Chain: fadeOut → fadeIn → animate margin. Length shows how many fx steps are still waiting.
Result
Ready — start a chain, then read length.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
Example 1 — Read fx Queue Length
Official idea: poll .queue("fx").length while a chain runs.
jQuery
var $box = $("#box");
function runIt() {
$box
.fadeIn("slow")
.animate({ marginLeft: 120 }, 1500)
.fadeOut("slow")
.fadeIn(800, runIt);
}
function showIt() {
$("#len").text($box.queue("fx").length);
setTimeout(showIt, 100);
}
runIt();
showIt();
Start. Custom queues do not auto-run — call .dequeue("tasks").
Edge Cases & Pitfalls
Common mistakes that stall or clear the wrong queue.
stall
Forgot next() / .dequeue()
Custom queue functions that never advance leave later effects stuck forever.
named
Named queues do not auto-start
Unlike fx, you must call .dequeue("name") to run the first function.
[]
[] clears pending, not the current tween
Pair with .stop() (or .finish()) when you also need to halt the active animation.
read
Read overload returns an Array
Do not chain jQuery methods on the result of .queue() with no args — use .length on the array.
vs clear
.clearQueue() vs .queue("fx", [])
Both drop pending items. Prefer .clearQueue() when you only need to empty — clearer intent.
Compatibility
Browser Support
.queue() has been part of jQuery since 1.2 (the next callback argument since 1.4). It works in every browser that runs your loaded jQuery version — no separate browser feature flag.
✓ Stable · jQuery 1.2+
jQuery .queue()
Supported across jQuery 1.x, 2.x, and 3.x. Prefer a current jQuery 3.x build. Queue behavior is part of jQuery’s fx engine.
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
.queue()Universal
Bottom line: Safe for everyday effect chains. Always call next()/dequeue() in custom steps, and clear with [] or .clearQueue() when cancelling.
Analysis
Performance Notes
Approach
Cost
Best for
Short effect chains
Cheap
Typical UI motion
Huge pending queues
Wasted work
Clear with [] / .clearQueue()
Polling .queue().length
Fine for demos
Avoid tight loops in production
Queues themselves are inexpensive. Cost comes from the animations waiting in them — cancel early when the user navigates away or spam-clicks a control.
Remember
Key Takeaways
Role: read, add, or replace the function queue (default fx).
Three forms: Array read · callback add · array replace.
Rule: custom steps must call next() or .dequeue().
Cancel:.queue("fx", []) + .stop() (or use .clearQueue()).
One line:.queue() is the control panel for waiting functions — inspect, append, or replace the line, and always advance custom steps.
Frequently Asked Questions
.queue() shows, adds to, or replaces the function queue on matched elements. With no callback or array it returns an Array of pending functions. With a callback it appends that function. With an array it replaces the entire queue contents.
1) .queue([queueName]) — returns Array (default queueName "fx"). 2) .queue([queueName], callback) — adds a function; returns jQuery; callback receives next() since 1.4. 3) .queue([queueName], newQueue) — replaces the queue with an Array (e.g. [] to empty it).
"fx" is jQuery’s default effects queue. Methods like .slideUp(), .fadeIn(), and .animate() push steps onto fx and run them one at a time. Chaining $("#foo").slideUp().fadeIn() runs slideUp first; fadeIn waits until slideUp finishes.
When jQuery runs a function you added with .queue(fn), it pauses until you signal completion. Call $(this).dequeue() or the next() argument so the following step can run. Without that signal, the chain stalls.
.queue(fn) adds a standalone step at the end of the queue — useful when the previous method has no callback parameter. An animate/slideUp callback runs when that specific animation completes. Both can sit mid-chain; .queue() works with any chained method.
It replaces the fx queue with an empty array, removing all pending functions that have not yet run. Pair with .stop() to also halt the current effect. .clearQueue() is a dedicated API for clearing pending items.