Toolbox-XToolbox-X

Throttle Function/Action

Creates a throttled version of a callback that ensures it executes at most once every specified interval.

throttleAction

Creates a throttled version of a callback that ensures it executes at most once every specified interval. Ideal for controlling calls on rapid, repeat events like scrolling or resizing.

Function Signature

function throttleAction<T extends VoidFn>(
  callback: T,
  delay?: number
): DelayedFn<T>

Parameters

ParameterTypeDescriptionDefault
callbackVoidFnThe function to throttle.
delaynumber (optional)Delay interval in milliseconds.150

Returns

  • DelayedFn<T>: A throttled version of the callback function.

Example Usage

playground.ts

Behavior Details

  • Interval Execution: Once triggered, the function will execute immediately (leading edge), and ignore subsequent invocations until the specified delay interval has elapsed.
  • Performance Protection: Helps prevent high-frequency event listeners (like scroll, mousemove, or resize) from blocking the browser's rendering thread.

Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)

On this page