The locked() method asks whether a Callbacks list has been frozen with lock(). It returns a boolean and changes nothing. This tutorial covers syntax, five examples, and how it pairs with lock(), disabled(), and safe registration patterns.
01
Syntax
callbacks.locked()
02
Boolean
true / false
03
Read-only
No side effects
04
vs lock()
Check vs action
05
vs disabled()
Different state
06
fire()
Still works
Fundamentals
Introduction
After you call lock(), the handler list is frozen — add(), remove(), and empty() silently do nothing. But other code may need to know whether that freeze already happened. Should we try to register a late handler? Is init complete?
locked() answers those questions. It is the status companion to lock(), just as disabled() complements disable() and fired() complements fire().
Concept
Understanding the locked() Method
callbacks.locked() returns true once lock() has been called on that list. On a brand-new list that has never been locked, it returns false.
It does not lock the list, return a new Callbacks object, or limit how many handlers run on fire(). The old reference incorrectly showed var lockedCallbacks = myCallbacks.locked() and described concurrency control — that is not how jQuery works.
💡
Beginner Tip
Memory trick: lock() does it; locked() asks “is it frozen?” — same pattern as fire() / fired() and disable() / disabled().
Foundation
📝 Syntax
General form of callbacks.locked:
jQuery
callbacks.locked()
Parameters
None.
Return value
true if the list has been locked; false otherwise.
A list can be locked but still active for firing, or disabled without ever being locked. Check the status that matches your question.
Applications
🚀 Use Cases
Registration guards — warn when add() is attempted after init closed.
Plugin APIs — expose isLocked() backed by locked().
Unit tests — assert lock() ran after setup phase.
Debugging — explain why late add() had no effect.
Lifecycle checks — branch logic when init locked hooks but events should still fire.
🧠 How locked() Fits the Lifecycle
1
New list
locked() is false — open for add/remove.
Open
2
lock()
List frozen; internal locked flag set to true.
Freeze
3
locked()
Status query returns true; no state change.
Query
=
✅
Informed registration
Code knows whether the handler set is still mutable.
Important
📝 Notes
locked() takes no parameters and returns a boolean only.
It does not return a Callbacks object — that was a documentation error in older material.
After lock(), locked() stays true permanently — no unlock() exists.
Do not confuse with disabled(), which tracks disable() instead.
fire() works when locked() is true; it does not when disabled() is true.
Compatibility
Browser Support
callbacks.locked() is part of jQuery’s Callbacks API since jQuery 1.7 and works wherever jQuery runs.
✓ jQuery 1.7+
jQuery Callbacks.locked()
Supported in jQuery 1.x, 2.x, and 3.x. Returns a boolean 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.locked()Universal
Bottom line: Safe in jQuery projects. Use lock() to freeze; use locked() to check freeze status.
Wrap Up
🎉 Conclusion
The callbacks.locked() method tells you whether a Callbacks list has been frozen with lock(). It is read-only, takes no arguments, and pairs naturally with lock() and the distinction from disabled().
Next, learn remove() to unregister specific handlers from an unlocked list.
locked() is a read-only status check. It returns true if lock() was called on the list, otherwise false. It does not lock anything itself — use lock() for the action.
lock() is the verb — it freezes the list so add(), remove(), and empty() stop working. locked() is the question — "is this list frozen?" It returns a boolean and changes nothing.
No. Unlike incorrect examples sometimes found online, locked() returns a boolean (true/false), not a separate callback list you can fire.
locked() tracks whether lock() was called. disabled() tracks whether disable() was called. A list can be locked but still fire handlers; a disabled list cannot fire at all.
After lock() runs on that Callbacks object. It stays true permanently — jQuery provides no unlock() method.
Common uses: skip add() when registration is closed, assert init completed before tests fire handlers, debug why late subscribers silently fail, and expose isLocked() in plugin APIs.
Did you know?
jQuery names Callbacks status methods consistently: lock() / locked(), disable() / disabled(), and fire() / fired() — verb for the action, past-participle-style name for the boolean check.