Creates a function that delays invoking func until after wait milliseconds have passed since the last call. Great for resize, search typing, and click spam. Includes cancel and flush. 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 _.debounce. Start with this line.
Lodash
_.debounce(func, [wait=0], [options={}])
Call
What it does
_.debounce(func, [wait=0], [options={}])
Primary signature.
_.debounce(func)
Wrap or transform a function.
Prefer import debounce from "lodash/debounce" when you want a smaller bundle.
Library declarations
Lodash
_.debounce(func, [wait=0], [options={}])
Parameters
Parameter
Description
func
Required. Function to delay
wait
Optional. Quiet-time delay in ms (default 0)
options.leading
Optional. Invoke on the start of a burst (default false)
options.trailing
Optional. Invoke after quiet time (default true)
options.maxWait
Optional. Maximum delay before a forced invoke
Return Value
Return Value
Description
*
Debounced function with cancel / flush
Lodash Examples
Example 1 — Default Trailing Debounce
Many rapid calls collapse into one run after quiet time.
Lodash
var runs = 0;
var save = _.debounce(function () {
runs += 1;
}, 120);
save();
save();
save();
// after ~120ms of quiet time → runs === 1
runs >= 1 (forced by maxWait during continuous calls)
How It Works
Problem. Without pauses, trailing debounce may never fire.
maxWait. Caps how long func can be delayed.
Docs. Same idea as batchLog on a message stream.
vs throttle. maxWait still “waits for quiet” when quiet exists.
Compatibility
Browser & Runtime Support
_.debounce 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. Uses timers under the hood (setTimeout); not a native language feature.
✓ Stable · Lodash 0.1+
_.debounce()
Available in [email protected] full builds and the lodash/debounce 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
_.debounceLodash 0.1+
Bottom line: Safe for production once Lodash is loaded. Prefer import debounce from "lodash/debounce" for smaller builds. Cancel pending calls on page/component teardown.
Frequently Asked Questions
_.debounce(func, wait, options) returns a function that delays calling func until wait ms have passed since the last wrapper call. Rapid calls reset the timer.
cancel() clears a pending trailing call. flush() runs a pending trailing call immediately and returns its result.
leading runs at the start of a burst. trailing (default true) runs after the burst ends. If both are true, trailing only fires when there was more than one call in the wait window.
When events never fully pause (continuous streams). maxWait guarantees func still runs at least that often.
debounce waits for quiet time. throttle caps how often func runs during ongoing activity.
The last arguments passed to the debounced wrapper.