Guide

Debounce

What @samline/debounce does, when to use debounce, throttle or rafThrottle, and where to start.

@samline/debounce controls how often a function runs. It ships three tools with the same returned controls:

ToolRunsUse it for
debounceOnce the calls stop for wait msSearch, validation, resize end
throttleAt most once every wait ms, plus the last call of a burstAutosave, analytics, progress
rafThrottleAt most once per animation frameScroll, pointer and layout reads

Every returned function forwards this and its arguments, returns the last result and has cancel(), flush() and pending().

Choose your next step