Creates a function that is restricted to invoking funconce. Repeat calls return the value of the first invocation. 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 _.once. Start with this line.
Lodash
_.once(func)
Call
What it does
_.once(func)
Primary signature.
_.once(func)
Wrap or transform a function.
Prefer import once from "lodash/once" when you want a smaller bundle.
Library declarations
Lodash
_.once(func)
Parameters
Parameter
Description
func
Required. Function invoked on the first call only
Return Value
Return Value
Description
*
Wrapper that freezes after first result
Lodash Examples
Example 1 — Official: Initialize Once
Call the wrapper twice; the inner function runs once.
Lodash
var calls = 0;
function createApplication() {
calls += 1;
return "app-ready";
}
var initialize = _.once(createApplication);
initialize();
initialize();
// calls → 1
once. Second call with 3 still returns 4 from the first run.
memoize. Key 3 is new → runs again → 6.
Rule. once = one result total; memoize = one result per key.
Pick. Init/setup → once; expensive pure lookups → memoize.
Compatibility
Browser & Runtime Support
_.once 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. There is no single native Function.once; Lodash remains the portable one-shot wrapper.
✓ Stable · Lodash 4.x
_.once()
Available in [email protected] full builds and the lodash/once 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
_.onceLodash 4.x+
Bottom line: Safe for production once Lodash is loaded. Prefer import once from "lodash/once" for smaller builds. Ideal for app boot, config loaders, and singleton setup.
Frequently Asked Questions
_.once(func) returns a wrapper that invokes func only on the first call. Later calls return that same first result without running func again.
The wrapper still receives them, but after the first run func is not called — only the stored return value is returned.
memoize caches many results keyed by argument. once remembers exactly one result for the whole wrapper, ignoring later argument differences.
_.before(n, func) lets func run for the first n−1 calls. _.once(func) is the same idea as before(2, func) — one real run.
Yes. Lodash invokes func with the this binding and arguments of the created function on that first call.
Use import once from "lodash/once" or require("lodash/once") for tree-shaking. Full build: import _ from "lodash" then _.once.