deferred.pipe() filters and/or chains a Deferred. Optional doneFilter, failFilter, and progressFilter map resolve, reject, and progress values. It returns a new Promise (since jQuery 1.6; progress filter since 1.7).
Remember
deferred.pipe(doneFilter [, failFilter [, progressFilter]])
doneFilter(value) → next success value or Promise
failFilter(reason) → next reject value (or Promise)
progressFilter(n) → next progress value
null / omitted filter → pass status & values through
prefer then() in new code
Create a Deferred, pipe filters, then resolve (or reject) the source.
Build a Deferred (or use a promise from AJAX / helpers).
Call pipe(doneFilter) — optionally add fail and progress filters.
Return a value or another promise from the filter.
Attach done() / fail() (or then()) on the piped promise.
In new code, write then() instead of pipe().
Piece
Required?
Role
doneFilter
Optional
Runs on resolve; return value feeds the chain
failFilter
Optional
Runs on reject; maps the failure path
progressFilter
Optional
Runs on notify() (since 1.7)
Return
—
New Promise representing the filtered chain
Pseudocode
Pseudocode
source = Deferred
piped = new Promise
when source resolves with value:
if doneFilter exists:
out = doneFilter(value)
if out is a Promise: wait, then settle piped like out
else: resolve piped with out
else:
resolve piped with value
when source rejects with reason:
// failFilter maps reason; plain return still rejects piped
// (return a resolved Deferred to recover)
prefer: source.then(doneFilter, failFilter)
Reference
Cheat Sheet
Keep these facts handy while reading legacy chains.
Topic
Detail
Syntax
deferred.pipe(done [, fail [, progress]])
Transform success
dfd.pipe(function (v) { return v * 2; })
Map reject
dfd.pipe(null, failFn)
Chain async
Return another Deferred / Promise from the filter
vs done()
done ignores return values; pipe does not
Modern swap
dfd.then(onFulfilled, onRejected)
Status
Deprecated since jQuery 1.8
Try it
Live Preview
Resolve a Deferred with 5, then see what pipe() (or then()) produces.
Browser demo of deferred.pipe — same idea as the examples below.
Result
defer.resolve(5)
pipe(n → n * 2)
→ 10
/* doneFilter transforms the resolve value */
Code
jQuery Examples
Short, copy-ready snippets. Open the browser console, or use Try It Yourself for a live editor.
Example 1 — Transform a Resolved Value
Multiply the resolve value in doneFilter; the piped promise gets the new number.
jQuery
var defer = $.Deferred();
var filtered = defer.pipe(function (value) {
return value * 2;
});
defer.resolve(5);
filtered.done(function (value) {
console.log(value); // 10
});
Modern path.then does the same transform and chains another then.
Same result. Both print 10 for this simple case.
Rule. New code: write then(); keep pipe() for legacy only.
Edge Cases & Pitfalls
Check these before relying on pipe() in real projects.
deprecated
Deprecated since 1.8
Official docs mark pipe() deprecated. Prefer then() for all new chains.
fail
Plain failFilter return still rejects
Returning a number/string from failFilter maps the reason but keeps the piped promise rejected. Return a resolved Deferred to recover to success.
done
done() does not transform
Return values from done() / fail() are ignored. Use pipe() or then() when the next step needs a new value.
then
then() rejection recovery differs
In jQuery 3+, returning a plain value from a then rejection handler fulfills the next promise (Promises/A+). pipe failFilter plain returns still reject — do not assume they match.
Compatibility
Browser Support
deferred.pipe() needs jQuery 1.6+ (progress filter since 1.7). It still works in jQuery 3.x but is deprecated since 1.8 — prefer then().
✓ jQuery 1.6+ · Deprecated 1.8
deferred.pipe()
Works in Chrome, Firefox, Safari, and Edge when jQuery 1.6+ is loaded. Use deferred.then() for new projects.
LegacyUse then()
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
pipe()Deprecated
Bottom line: Replace .pipe(fn) with .then(fn) in new code. Keep pipe() only while maintaining older chains.
Analysis
Performance Notes
Approach
Cost
Best for
pipe(fn)
One extra promise + filter call
Legacy transform chains
then(fn)
Same order of cost
All new jQuery 3+ code
done(fn)
Cheapest callback
Side effects with no transform
Pipeline cost is dominated by your async work (timers, AJAX), not by pipe vs then. Choose then() for API clarity and future maintenance, not micro-benchmarks.
Return matters: values and promises from filters feed the next link.
Migrate: use then() — pipe() is deprecated since 1.8.
failFilter: plain return still rejects; return a resolved Deferred to recover.
One line:pipe() transforms Deferred chains — learn it for legacy code, write then() for new work.
Frequently Asked Questions
pipe() returns a new Promise that filters a Deferred’s resolve, reject, and (optionally) progress values. doneFilter runs on resolve; failFilter on reject; progressFilter on notify. Return a value or another promise to feed the next step.
Yes. As of jQuery 1.8, deferred.pipe() is deprecated. Use deferred.then() instead — it replaces pipe() and follows Promises/A+ semantics in jQuery 3+.
done() only registers a side-effect callback — its return value is ignored. pipe() (and then()) use the filter’s return value as the next link’s input.
The piped promise stays rejected, but with the new value. Official pattern: map the reason, then attach .fail(). To recover into success, return a resolved Deferred from failFilter.
Yes. Return a Deferred or Promise from doneFilter; the piped chain waits until that promise settles, then continues with its value.
No. Prefer then(onFulfilled, onRejected) in jQuery 3+. Keep pipe() only when reading or maintaining legacy jQuery 1.x/2.x chains.