jQuery callbacks.locked() Method — Check Lock Status
Beginner
4 min read
Updated: Oct 2026
4 examples
Live preview
Definition
What Is locked()?
callbacks.locked() returns a Boolean: true if lock() has frozen that Callbacks list (since jQuery 1.7). It does not change the list or run handlers.
Remember
callbacks.locked() // false before lock
callbacks.lock()
callbacks.locked() // true after
lock() → freeze state (action)
locked() → boolean status (question)
Ask before you publish again — after a freeze, new fires are ignored.
Build the list, add() handlers, and fire() as needed.
Call locked() — expect false before any lock.
Call lock() when the state should stop changing.
Call locked() again — expect true from then on.
Piece
Required?
Role
Callbacks object
Yes
From $.Callbacks()
Arguments
None
locked() takes no parameters
Return
—
Boolean — has lock() run?
Pseudocode
Pseudocode
function locked(callbacks):
return callbacks.hasBeenLocked
// After lock():
// hasBeenLocked = true
// There is no unlock() — stays true for this object
Reference
Cheat Sheet
Read-only lock status — pair with lock() for the action.
var cbs = $.Callbacks("memory");
cbs.add(function (v) { console.log(v); });
cbs.fire("ok");
cbs.lock();
console.log(cbs.locked()); // true
console.log(cbs.disabled()); // false (memory list still usable for late adds)
callbacks.locked() has shipped since jQuery 1.7 with $.Callbacks. It works in all modern browsers with jQuery loaded.
✓ jQuery 1.7+
callbacks.locked()
Return true if lock() has frozen 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.locked()Excellent
Bottom line: Call locked() to read status. Call lock() when you want to freeze the list.
Analysis
Performance Notes
Approach
Cost
Best for
locked()
O(1)
Status guards
lock() then check
O(1)
Finalize + assert
Own boolean flag
O(1)
Only if you avoid Callbacks
Prefer locked() over a parallel custom flag when you already use $.Callbacks — one source of truth.
Remember
Key Takeaways
Role: boolean — has lock() run?
Read-only: does not freeze or fire.
vs disabled: different flag, different meaning.
Sticky: no unlock — stays true.
One line:locked() asks “did lock() already freeze this list?”
Frequently Asked Questions
locked() returns true if lock() has been called on the Callbacks list; otherwise false. It is a status check only — it does not lock the list or invoke handlers.
No. locked() accepts no arguments. Flags such as memory belong on $.Callbacks("…") when you create the list.
lock() is the action that freezes the list. locked() answers whether that action has happened. It returns a boolean and does not change the list.
locked() tracks whether lock() froze the list. disabled() tracks whether disable() shut it down. A list can be locked without being disabled (especially with the memory flag).
No. There is no unlock() API. Once locked() is true, it stays true for that Callbacks object. Create a new $.Callbacks() list if you need a fresh unlockable list.
Guard publish helpers so you do not fire after a freeze, assert teardown order in tests, or branch UI/plugin logic that depends on a finalized Callbacks state.