Lodash _.throttle() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

Creates a function that invokes func at most once every wait milliseconds. Great for scroll, resize, and mousemove. 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 _.throttle. Start with this line.

Lodash
_.throttle(func, [wait=0], [options={}])
CallWhat it does
_.throttle(func, [wait=0], [options={}])Primary signature.
_.throttle(func)Wrap or transform a function.

Prefer import throttle from "lodash/throttle" when you want a smaller bundle.

Library declarations
Lodash
_.throttle(func, [wait=0], [options={}])

Parameters

ParameterDescription
funcRequired. Function to rate-limit
waitOptional. Minimum ms between invokes (default 0)
options.leadingOptional. Invoke on the start of a window (default true)
options.trailingOptional. Invoke at the end of a window (default true)

Return Value

Return ValueDescription
*Throttled function with cancel / flush

Lodash Examples

Example 1 — Default Leading + Trailing

A tight burst often yields two runs with the default options.

Lodash
var runs = 0;
var tick = _.throttle(function () {
  runs += 1;
}, 100);

for (var i = 0; i < 30; i++) tick();

// after ~150ms → runs === 2  (leading + trailing)
Try It Yourself

How It Works

  1. Leading. First call invokes func immediately.
  2. Burst. More calls inside 100 ms do not start new leading invokes.
  3. Trailing. Because there was more than one call, a trailing invoke fires after the window.
  4. Count. Typical result for this spam pattern: 2.

Example 2 — Official Scroll Pattern

Cap how often a position updater runs while scrolling.

Lodash
function updatePosition() {
  // read scrollY / layout work
}

window.addEventListener(
  "scroll",
  _.throttle(updatePosition, 100)
);
Try It Yourself

How It Works

  1. Noise. Scroll fires many times per second.
  2. Cap. Throttle keeps updates to ~10/sec with wait: 100.
  3. Feel. UI still tracks motion without flooding layout work.
  4. Docs. Matches the official jQuery scroll example.

Example 3 — Official trailing: false

Run on the leading edge only — ignore a trailing catch-up call.

Lodash
var runs = 0;
var renew = _.throttle(function () {
  runs += 1;
}, 100, { trailing: false });

for (var i = 0; i < 30; i++) renew();

// after wait → runs === 1  (leading only)
Try It Yourself

How It Works

  1. Leading. First call runs immediately.
  2. No trailing. Extra calls in the window do not schedule an end-of-window run.
  3. Docs. Same idea as renewToken with { trailing: false }.
  4. Use. Actions that should not “catch up” after the burst.

Example 4 — Cancel a Pending Call

Drop a scheduled trailing invocation (e.g. on navigation).

Lodash
var runs = 0;
var tick = _.throttle(function () {
  runs += 1;
}, 200);

tick();
tick();
tick.cancel();

// after wait → runs === 1  (leading ran; trailing cancelled)
Try It Yourself

How It Works

  1. Leading. First tick() increments runs immediately.
  2. Trailing pending. Second call schedules an end-of-window invoke.
  3. Cancel. tick.cancel() clears that pending call.
  4. Docs. Same idea as cancelling on popstate.

Example 5 — _.throttle vs _.debounce

Same burst, different strategies.

Lodash
var tRuns = 0, dRuns = 0;
var t = _.throttle(function () { tRuns += 1; }, 100);
var d = _.debounce(function () { dRuns += 1; }, 100);

for (var i = 0; i < 20; i++) { t(); d(); }

// after ~150ms:
// tRuns → 2  (leading + trailing during the burst)
// dRuns → 1  (one call after quiet time)
Try It Yourself

How It Works

  1. Throttle. Keeps firing on a schedule while activity continues.
  2. Debounce. Waits until calls stop, then runs once.
  3. Pick. Scroll/resize → throttle; search typing → debounce.
  4. Docs. See David Corbacho’s article linked from the Lodash docs for deeper nuance.

Browser & Runtime Support

_.throttle is a long-standing Lodash 4.x Function helper (since 0.1.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 0.1.0+

_.throttle()

Available in [email protected] full builds and the lodash/throttle modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.throttle Lodash 0.1.0+

Bottom line: Safe for production once Lodash is on the page or in your bundle. Prefer import throttle from "lodash/throttle" for smaller builds. For quiet-time delays, use _.debounce.

Frequently Asked Questions

_.throttle(func, wait, options) returns a function that invokes func at most once every wait milliseconds while calls keep arriving. Defaults use leading and trailing edges.
Debounce waits for quiet time after the last call. Throttle guarantees periodic execution during continuous bursts — better for scroll and resize listeners.
cancel() drops a pending delayed invocation. flush() immediately invokes a pending trailing call when configured.
The last arguments provided to the throttled wrapper.
Trailing fires only if the wrapper was invoked more than once during the wait window — so a rapid burst often yields two runs (leading + trailing), not one.
Use import throttle from "lodash/throttle" or require("lodash/throttle") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.throttle.

Next: _.unary()

Create a function that accepts only one argument — useful with map/parseInt pitfalls.

_.unary() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful