Defers invoking func until the current call stack has cleared. Extra arguments are forwarded to func. Returns a timer id. Part of Lodash 4.x Function (since 0.1.0).
Pass the required arguments shown below. Most helpers return a new function you call later.
Syntax
Call _.defer. Start with this line.
Lodash
_.defer(func, [args])
Call
What it does
_.defer(func, [args])
Primary signature.
_.defer(func)
Wrap or transform a function.
Prefer import defer from "lodash/defer" when you want a smaller bundle.
Library declarations
Lodash
_.defer(func, [args])
Parameters
Parameter
Description
func
Required. Function to run after the stack
args
Optional. Arguments forwarded to func
Return Value
Return Value
Description
*
Timer id (number)
Lodash Examples
Example 1 — Official: Defer a Log
Schedule a callback with one argument.
Lodash
var message = "";
_.defer(function (text) {
message = text;
}, "deferred");
// after stack clears → message === "deferred"
defer. Runs as soon as the stack is clear (~1 ms).
delay. Waits the given 50 ms.
Order."defer" appears first, then "delay".
Pick. Use delay when timing matters to the user.
Compatibility
Browser & Runtime Support
_.defer is a Lodash 4.x Function helper (since 0.1.0). It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Built on timer APIs similar to setTimeout.
✓ Stable · Lodash 0.1+
_.defer()
Available in [email protected] full builds and the lodash/defer modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.deferLodash 0.1+
Bottom line: Safe for production once Lodash is loaded. Prefer import defer from "lodash/defer" for smaller builds. Use when you need work after the current stack, not a user-facing delay.
Frequently Asked Questions
_.defer(func, ...args) schedules func to run after the current call stack has cleared. Extra args are passed to func.
A timer id (number), like setTimeout — you can clearTimeout it if needed.
defer always waits until the stack clears (tiny timer). delay lets you choose any wait in milliseconds.
No. It uses timer scheduling (macrotask), not Promise.then / queueMicrotask.
When synchronous setup must finish first — then run a follow-up without blocking the current stack.
Officially about one millisecond after the stack clears — not a user-chosen delay.