callbacks.remove(callbacks) removes a function — or an array of functions — from a Callbacks list (since jQuery 1.7). Later fire() calls skip those handlers. Returns the same Callbacks object for chaining.
Remember
callbacks.add(foo)
callbacks.fire("hello") // foo runs
callbacks.remove(foo)
callbacks.fire("world") // nothing — foo is gone
remove(fn) // one handler
remove([a, b]) // several at once
Keep the reference, then remove it when you unsubscribe.
Store handlers in named variables.
add() them to the list and use fire() as needed.
Call remove(fn) or remove([fn1, fn2]) to unsubscribe.
Optional: confirm with has(fn) — expect false.
Piece
Required?
Role
callbacks
Yes
Function or array of functions to remove
Return
—
Same Callbacks object (chainable)
Pseudocode
Pseudocode
function remove(callbacks, targets):
for each fn in (targets as list):
if fn is in callbacks.list: // reference match
delete fn from list
return callbacks
Pass an array to unregister more than one handler.
jQuery
var lines = [];
var a = function () { lines.push("a"); };
var b = function () { lines.push("b"); };
var c = function () { lines.push("c"); };
var cbs = $.Callbacks();
cbs.add(a).add(b).add(c);
cbs.remove([a, b]);
cbs.fire();
console.log(lines.join("")); // "c"
var onReady = function () {
console.log("ready");
};
var cbs = $.Callbacks();
cbs.add(onReady);
console.log(cbs.has(onReady)); // true
cbs.remove(onReady);
console.log(cbs.has(onReady)); // false
Pick one handler to drop, or clear the whole list.
jQuery
var lines = [];
var keep = function () { lines.push("keep"); };
var drop = function () { lines.push("drop"); };
var cbs = $.Callbacks();
cbs.add(keep).add(drop);
cbs.remove(drop); // only drop is gone
cbs.fire();
console.log(lines.join(",")); // keep
cbs.empty(); // clears keep too
cbs.fire();
console.log(lines.join(",")); // keep (unchanged)
Most failures come from losing the original function reference.
identity
Anonymous twins do not match
add(function(){}) then remove(function(){}) fails — different objects, same text.
empty
Need a full reset?
Use empty() instead of removing every handler one by one.
missing
Removing a missing handler is safe
remove(fn) quietly does nothing if fn is not on the list.
fired
Does not reset fired()
Removing handlers does not clear the fired flag — that tracks past fire() / fireWith() calls.
Compatibility
Browser Support
callbacks.remove() has shipped since jQuery 1.7 with $.Callbacks. It works in all modern browsers with jQuery loaded.
✓ jQuery 1.7+
callbacks.remove()
Unregister a function or array of functions from the Callbacks list.
100%Browser support
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.remove()Excellent
Bottom line: Pass the same function reference you added. Use empty() when you need to clear everything.
Analysis
Performance Notes
Approach
Cost
Best for
remove(fn)
O(n) scan
Drop one subscriber
remove([a,b])
O(n × k)
Drop a small batch
empty()
O(1) clear
Wipe the whole list
Lists are usually short. Prefer named handlers and targeted remove for unsubscribe paths.
Remember
Key Takeaways
Role: unregister specific handlers.
Args: one function or an array of them.
Identity: same reference you add()ed.
vs empty: remove some; empty clears all.
One line:remove(fn) unsubscribes the same function object you added.
Frequently Asked Questions
remove(callbacks) unregisters a function — or an array of functions — from a Callbacks list. Later fire() calls no longer invoke those handlers. It returns the same Callbacks object for chaining.
Yes. remove() matches by identity, just like has(). Keep a named variable for the handler you add(), then pass that same variable to remove().
remove(fn) drops specific handlers. empty() clears every handler on the list at once.
Yes. Pass an array: callbacks.remove([foo, bar]). You can also pass a single function.
remove() is safe — it simply finds nothing to remove and returns the Callbacks object. No error is thrown.
Unsubscribe a plugin listener, clean up a specific subscriber on destroy, or drop one handler while leaving others on the list.