$.Deferred() is the factory that creates jQuery Deferred objects — the building blocks behind $.ajax() callbacks, custom async helpers, and promise-style chains. This tutorial covers creation, resolve/reject, returning promise(), and five hands-on examples.
01
Create
$.Deferred()
02
Resolve
Success path
03
Reject
Failure path
04
promise()
Read-only export
05
States
pending → settled
06
Since 1.5
Core jQuery API
Fundamentals
Introduction
Asynchronous programming keeps web pages responsive while network calls, timers, and animations run in the background. jQuery has supported this pattern since version 1.5 with Deferred objects — and $.Deferred() is how you create them.
Think of a Deferred as a ticket for work that will finish later. You hand the ticket to callers so they can register done() and fail() handlers; when your async task completes, you call resolve() or reject() to settle the ticket.
Concept
Understanding the $.Deferred() Method
$.Deferred() (identical to jQuery.Deferred()) is a constructor-style factory — not a method on an existing Deferred. Each call returns a fresh Deferred object representing one async operation with three possible states:
pending — work still running; callbacks are queued.
resolved — success; done() and always() handlers run.
rejected — failure; fail(), catch(), and always() handlers run.
Once resolved or rejected, the state is frozen — calling resolve() again has no effect. That guarantee makes Deferred objects predictable in chained workflows.
💡
Beginner Tip
When you return async work from your own function, create a Deferred internally, call resolve or reject when finished, and return dfd.promise() so outside code cannot accidentally resolve your task early.
This pattern mirrors how you would wrap legacy callback APIs before native Promises were common — one Deferred per operation, settled when the underlying work finishes.
Example 5 — Optional Constructor Callback
Pass a function to $.Deferred(); it runs immediately with the Deferred as this.
The optional callback starts work as soon as the Deferred exists. Pair it with notify() and progress() for long-running tasks — see the progress tutorial for deeper coverage.
Applications
🚀 Use Cases
AJAX wrappers — unify success and error callbacks before fetch was standard.
Animation coordination — resolve a Deferred when a .fadeOut() animation completes.
Parallel tasks — combine multiple Deferreds with $.when() (covered on the Deferred hub).
Timeouts — reject if work exceeds a deadline using setTimeout plus reject().
Plugin APIs — return promise() from jQuery plugins so callers chain done() naturally.
🧠 Deferred Lifecycle
1
Create
const dfd = $.Deferred() — state is pending.
Factory
2
Register
Callers attach done, fail, or always handlers while pending.
Queue
3
Settle
You call resolve(value) or reject(reason) once work finishes.
Settled
=
🔗
Callbacks run
Handlers fire in order; chains continue via then() if you return new promises.
Important
📝 Notes
$.Deferred() and jQuery.Deferred() are the same function.
Resolve or reject exactly once; subsequent calls are ignored.
Handlers registered after settlement still run immediately (if they match the state).
Prefer returning promise() from public APIs to hide resolve/reject.
Modern greenfield apps often use native Promise, but jQuery Deferred remains useful in legacy codebases.
Compatibility
Browser Support
jQuery.Deferred() has been part of jQuery since version 1.5. It runs wherever jQuery runs — no separate polyfill required.
✓ jQuery 1.5+
jQuery.Deferred()
Available in jQuery 1.5+, 2.x, and 3.x across all browsers supported by your 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
$.Deferred()Universal
Bottom line: Load jQuery 3.7+ for the latest Promises/A+ helpers (then, catch). The constructor itself works in every jQuery version that ships Deferred.
Wrap Up
🎉 Conclusion
$.Deferred() is the starting point for custom async workflows in jQuery. Create an object, register callbacks, settle with resolve or reject, and optionally export promise() to callers.
Master this factory and the rest of the Deferred API — done, fail, always, and then — clicks into place.
$.Deferred() (same as jQuery.Deferred()) is a factory function that creates a new Deferred object — a stateful handle for an async operation you control with resolve(), reject(), and callback methods like done() and fail().
A Deferred is the full object: you can resolve or reject it. promise() returns a read-only view that exposes done/fail/then but hides resolve/reject — use it when returning async work to other code.
pending (not finished), resolved (success), or rejected (failure). After resolving or rejecting, the state is locked — you cannot change it again.
Yes. An optional callback runs immediately with the new Deferred as this. It is useful for kicking off async setup and calling resolve/reject when finished.
jqXHR objects from $.ajax() implement the Deferred interface. $.Deferred() lets you build the same callback patterns for your own async functions.
Deferred objects were added in jQuery 1.5. They are available in all modern jQuery 1.x, 2.x, and 3.x releases.
Did you know?
jQuery introduced Deferred objects in 2011 (jQuery 1.5) partly to unify the messy callback options on $.ajax() — the same object you create with $.Deferred() powers jqXHR under the hood.