callbacks.add() appends one or more functions to a jQuery Callbacks list (since jQuery 1.7). It queues handlers; they run when you call fire() or fireWith(). Returns the same Callbacks object for chaining.
Remember
callbacks.add( fn )
callbacks.add( fn1, fn2 ) // multiple args
callbacks.add( [fn1, fn2] ) // array of functions
add() → queue (does not run)
fire() → run every handler in order
returns the Callbacks object (chainable)
Create a list, register handlers, then fire when the event or step is ready.
Create a list with $.Callbacks() (optional flags: once, memory, unique, stopOnFalse).
Call add(fn) — or pass several functions / an array.
Trigger with fire() or fireWith(context, args) when you want handlers to run.
Use remove() / empty() when a handler should no longer run.
Piece
Required?
Role
Callbacks object
Yes
From $.Callbacks()
callback / array
Yes
Function(s) to append
Return
—
Same Callbacks object (chainable)
Pseudocode
Pseudocode
list = empty callback queue
add(fn or [fn…]):
if list is locked or disabled:
ignore
else if flag "unique" and fn already in list:
skip duplicate
else:
append fn to list
if flag "memory" and list already fired:
run fn now with last args
fire(args…):
for each fn in list (registration order):
call fn(args…)
Reference
Cheat Sheet
Keep these facts handy while wiring Callbacks lists.
Topic
Detail
Syntax
callbacks.add(callbacks)
Argument
Function, multiple functions, or array of functions
Runs now?
No (unless memory + already fired)
Order
First added → first called (FIFO)
Duplicates
Allowed by default; use "unique" to block
Return
Same Callbacks object
Since
jQuery 1.7
Try it
Live Preview
Pick how to register handlers on a fresh $.Callbacks() list, then fire with "hello".
Browser demo of callbacks.add — same idea as the examples below.
Core fires at the right time. After rendering, fire(items) notifies hooks.
Loose coupling. Core never hard-codes the analytics function.
Edge Cases & Pitfalls
Check these before relying on add() in real projects.
queue
add() does not run handlers
It only queues. Pair with fire() / fireWith() (unless the list has memory and already fired).
re-fire
Default lists re-run everyone
A second fire() calls all current handlers again — not only newly added ones.
memory
memory runs late adds immediately
With $.Callbacks("memory"), adding after a fire invokes the new handler right away with the last args (Deferred-style).
unique
Duplicates allowed by default
The same function reference added twice runs twice. Use "unique" or check has(fn) first.
lock
Locked / disabled lists drop adds
After lock() or disable(), new add() calls do not stick. Inspect locked() / disabled() when debugging.
Compatibility
Browser Support
callbacks.add() is part of jQuery’s Callbacks API (since 1.7). It works in any browser where your jQuery build runs — the list logic lives in jQuery, not as a separate browser API.
✓ jQuery 1.7+ · Browsers
jQuery callbacks.add()
Supported in jQuery 1.x, 2.x, and 3.x across Chrome, Firefox, Safari, Edge, and other browsers with jQuery loaded.
100%With jQuery loaded
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
callbacks.add()Browsers
Bottom line: Safe wherever jQuery is loaded. Create lists with the right flags (once, memory, unique) before calling add().
Analysis
Performance Notes
Operation
Cost
Best for
add(fn)
O(1) append*
Registering handlers
fire()
O(n) handlers
Invoking the full list
add with unique
O(n) membership check
Preventing duplicate refs
*Default append is cheap; unique walks the list to reject duplicates. Keep handlers light — heavy work inside callbacks blocks the whole fire() pass. Prefer named function references so remove() can find them later.
Remember
Key Takeaways
Role:add() queues handlers; fire() runs them.
Input: one function, many args, or an array of functions.
Flags:memory, unique, and once change add/fire behavior — set them at creation.
Plugins: expose a Callbacks list so callers can add() hooks safely.
One line:add() is how you subscribe — fire() is how you publish.
Frequently Asked Questions
add() registers one or more functions on a jQuery Callbacks list. Those functions run later when you call fire() or fireWith() on the same list. add() itself does not run the callbacks.
Yes. Pass separate function arguments — callbacks.add(fn1, fn2) — or an array — callbacks.add([fn1, fn2]). Both append handlers in order. The official API accepts a Function or an Array of functions.
Not on a default list. Handlers wait until fire() or fireWith(). With the memory flag, a handler added after the list has already fired runs right away with the last memorized arguments.
By default, duplicates are allowed and each copy runs on fire(). Create the list with $.Callbacks("unique") to reject duplicate references.
After lock(), new add() calls are ignored. After disable(), the list is shut down and further adds and fires are effectively no-ops. Check locked() / disabled() when debugging missing handlers.
jQuery Deferred uses Callbacks lists internally for done, fail, and progress queues (typically with once and memory). Calling .done(fn) is conceptually like add(fn) on that internal list.