The remove() method unregisters specific function references from a jQuery Callbacks list — the counterpart to add(). This tutorial covers syntax, five examples, comparisons with empty(), and unsubscribe patterns for event buses and plugins.
01
Syntax
remove(fn)
02
Reference
Same function object
03
vs add()
Unregister
04
vs empty()
One vs all
05
has()
Check first
06
lock()
Blocks remove
Fundamentals
Introduction
You use add() to subscribe handlers to a Callbacks list. When a component unmounts, a user logs out, or a one-time listener is no longer needed, those handlers should come off the list — otherwise the next fire() still invokes them.
remove() is how you unsubscribe. Pass the same function reference you used with add(), and jQuery drops it from the queue.
Concept
Understanding the remove() Method
callbacks.remove(callback [, callback]) removes one or more handlers from the list by reference. Removed functions no longer run on subsequent fire() or fireWith() calls. The method returns the same Callbacks object for chaining.
It does not clear the entire list when called with no arguments. The old reference incorrectly stated that omitting the callback removes all handlers — use empty() for that. Matching is by reference, same as has().
💡
Beginner Tip
Keep a named reference to every handler you may unsubscribe later. Anonymous functions added inline cannot be removed unless you stored them in a variable first.
Foundation
📝 Syntax
General form of callbacks.remove:
jQuery
callbacks.remove( callback [, callback ] )
Parameters
callback — One or more function references to remove from the list. Each must match a handler previously added with add().
Return value
Returns the same Callbacks object (supports chaining).
Unregister specific handlers versus register versus wipe all.
add(fn)
register
Put handler on list
remove(fn)
unregister
Drop specific reference
empty()
clear all
Remove every handler
After lock()
no-op
remove() silently ignored
Hands-On
Examples Gallery
Each example shows a different way to use remove() in real Callbacks workflows.
📚 Getting Started
Drop one handler; the rest still fire.
Example 1 — Remove One Handler
Add two handlers, fire, remove one, then fire again.
jQuery
const callbacks = $.Callbacks();
function foo() { console.log("Foo"); }
function bar() { console.log("Bar"); }
callbacks.add(foo);
callbacks.add(bar);
callbacks.fire(); // Foo, Bar
callbacks.remove(foo);
callbacks.fire(); // Bar only
Component teardown — drop handlers when a widget is destroyed.
One-time listeners — remove self inside the handler after first fire.
Duplicate cleanup — remove extra copies of the same reference.
Plugin APIs — let users detach custom hooks they no longer need.
🧠 How remove() Updates the List
1
add() handlers
Functions registered on the Callbacks list.
Register
2
remove(fn)
Matching references dropped by identity lookup.
Unregister
3
fire()
Only remaining handlers run.
Invoke
=
✅
Lean handler set
Stale subscribers no longer run on future events.
Important
📝 Notes
Pass the exact function reference — remove() does not match by name or source code.
Use empty() to clear all handlers; do not omit args from remove() for that.
After lock(), remove() is a no-op.
Removing a handler that is not on the list is safe — jQuery ignores it silently.
has(fn) returns false immediately after a successful remove(fn).
Compatibility
Browser Support
callbacks.remove() is part of jQuery’s Callbacks API since jQuery 1.7 and works wherever jQuery runs.
✓ jQuery 1.7+
jQuery Callbacks.remove()
Supported in jQuery 1.x, 2.x, and 3.x. Reference-based removal behaves consistently across browsers.
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.remove()Universal
Bottom line: Safe in jQuery projects. Store references for handlers you plan to remove later.
Wrap Up
🎉 Conclusion
The callbacks.remove() method unregisters specific handlers from a Callbacks list by function reference. It pairs with add(), contrasts with empty() for bulk clearing, and respects lock() when the list is frozen.
You have now covered the full jQuery Callbacks API. Next, explore Deferred — which uses Callbacks lists internally for promise-style async workflows.
Store named references for handlers you will remove
Wrap remove() in off() / unsubscribe() APIs
Use has() before remove when membership is uncertain
Prefer empty() when dropping every handler
Remove hooks during component/plugin teardown
❌ Don’t
Expect remove() with no args to clear the list
Try to remove anonymous inline functions without a reference
Call remove() after lock() expecting success
Confuse remove() with disable()
Forget to unsubscribe — causes memory leaks and duplicate runs
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about remove()
Unregister handlers from Callbacks lists.
5
Core concepts
−01
remove(fn)
Unregister
API
🔗02
Reference
Same object
Match
+03
add()
Opposite
Pair
∅04
empty()
Clear all
Compare
🔒05
lock()
Blocks remove
Control
❓ Frequently Asked Questions
remove(callback) unregisters one or more function references from a Callbacks list. After removal, those functions no longer run on the next fire(). It does not run callbacks — it only drops them from the queue.
No. Unlike incorrect documentation sometimes found online, remove() requires the callback reference(s) you want to drop. To wipe every handler at once, use empty() instead.
remove(fn) drops specific handlers you pass by reference. empty() clears the entire list in one call — useful when you do not need to name each function.
No. Once lock() freezes the list, remove() becomes a silent no-op — same as add(). Check locked() before attempting removal.
Yes. Pass multiple function references: callbacks.remove(fn1, fn2, fn3). Each matching handler is removed from the list.
Both use reference equality. After remove(fn), has(fn) returns false. Use has() first when you are unsure whether a handler is still registered.
Did you know?
jQuery’s unique flag on $.Callbacks("unique") prevents duplicate references at add() time — but if duplicates slip in without that flag, remove(fn) drops only the first matching entry per call.