The empty() method removes every handler from a jQuery Callbacks list in one step. The list stays active — you can add() and fire() again afterward. This tutorial covers syntax, five examples, and how empty() differs from remove() and disable().
01
Syntax
callbacks.empty()
02
Clear all
Every handler
03
Re-use
List stays live
04
vs remove()
One vs many
05
vs disable()
Clear vs kill
06
Reset
Event buses
Fundamentals
Introduction
Callback lists grow as features subscribe to events — click handlers, AJAX hooks, plugin extensions. Over time you may need to wipe every subscriber without destroying the list itself. That is what empty() does: one call, zero handlers left.
Unlike disable(), which permanently turns firing off, empty() only clears the queue. You can register fresh handlers and continue using the same Callbacks object — ideal for resettable event buses and multi-step workflows.
Concept
Understanding the empty() Method
callbacks.empty() takes no arguments and removes all functions currently stored in the list. It also clears internal firing memory associated with those handlers, so the next fire() starts from a clean slate.
After empty(), calling fire() does nothing until you add() at least one new handler. The list is not disabled — disabled() remains false unless you previously called disable().
💡
Beginner Tip
Use empty() when you want to reset subscribers. Use disable() when the list should never fire again — such as after plugin destroy.
Foundation
📝 Syntax
General form of callbacks.empty:
jQuery
callbacks.empty()
Parameters
None.
Return value
Returns the same Callbacks object for method chaining.
Basic pattern
jQuery
const callbackList = $.Callbacks();
callbackList.add(function () { console.log("Callback 1"); });
callbackList.add(function () { console.log("Callback 2"); });
callbackList.empty();
callbackList.fire(); // no output — list is empty
Cheat Sheet
⚡ Quick Reference
Goal
Code
Remove all handlers
callbacks.empty()
Remove specific handlers
callbacks.remove(fn)
Shut down list permanently
callbacks.disable()
Clear then re-subscribe
callbacks.empty().add(fn)
Fire after empty (no handlers)
callbacks.fire() → no-op
Compare
📋 empty() vs remove() / disable()
Pick the method that matches how much of the list you want to change.
empty()
clear all
List stays active; add/fire again
remove()
drop fn
Remove one or more specific handlers
disable()
kill list
Permanent shutdown — no more firing
After empty
disabled: false
Unless disable() was called earlier
Hands-On
Examples Gallery
Each example demonstrates clearing handlers and what happens on the next fire().
📚 Getting Started
Remove every handler, then fire — nothing runs.
Example 1 — Clear All Callbacks
Add two handlers, call empty(), then fire() — silent.
Swapping handler sets is common in versioned plugin APIs — clear old, attach new, fire immediately.
Applications
🚀 Use Cases
Event handler reset — clear all listeners before rebinding on DOM refresh.
Wizard / multi-step UI — drop step-specific hooks when advancing.
Test isolation — empty shared Callbacks fixtures between test cases.
Memory hygiene — release handler references on long-lived SPAs without destroying the bus object.
Handler replacement — swap entire callback sets via empty().add(...).
🧠 How empty() Works
1
Handlers queued
add() builds a list of functions waiting for fire().
Subscribe
2
empty()
All handlers and firing memory are discarded; list object stays active.
Clear
3
Re-populate
Optional: add() new handlers and fire() again.
Reuse
=
🗑
Clean slate
Same bus object, zero stale subscribers.
Important
📝 Notes
empty() does not call disable() — the list can still fire after new add() calls.
On a list already disable()d, empty() does not re-enable firing.
If the list is lock()ed, mutating methods including empty() may be restricted — see the lock() tutorial.
Prefer remove(fn) when only one subscriber leaves.
After empty(), has(fn) returns false for all previous handlers.
Compatibility
Browser Support
callbacks.empty() is part of jQuery’s Callbacks API since jQuery 1.7 and works wherever jQuery runs.
✓ jQuery 1.7+
jQuery Callbacks.empty()
Supported in jQuery 1.x, 2.x, and 3.x across all browsers with a compatible jQuery build.
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.empty()Universal
Bottom line: Safe in jQuery projects. Use empty() for reset; use disable() for permanent shutdown.
Wrap Up
🎉 Conclusion
The callbacks.empty() method clears every handler from a Callbacks list while keeping the list itself active. It is the right tool for resets, step changes, and handler replacement — not for permanent teardown (use disable()).
Next, learn fire() — the method that invokes whatever handlers remain in the list.
empty() removes every handler from the Callbacks list in one call. After empty(), fire() runs nothing until you add() new functions. The list itself stays active — unlike disable(), which permanently shuts down firing.
remove(fn) drops specific function references you pass in. empty() wipes the entire list at once — useful when you want a clean slate without tracking each handler.
empty() clears handlers but the list can still accept add() and fire() afterward. disable() permanently prevents all future firing and clears internal state; disabled() stays true.
Yes. It returns the same Callbacks object, so you can chain: callbacks.empty().add(fn).fire().
Yes, but it is a no-op when no handlers remain. Add new callbacks first if you expect output.
empty() clears handlers, but if disable() was already called, the list remains disabled — disabled() stays true and fire() still does nothing. Use empty() on active lists you plan to reuse.
Did you know?
Calling empty() on a list with the memory flag clears stored fire arguments too — late add() callbacks will not replay old values until you fire() again.