Comparison
DebouncevsThrottle
Debounce
you wait until the user stops typing for three hundred milliseconds and only then send the request.
Delaying a call until a quiet period has passed, resetting the timer on every new event, so a burst produces exactly one call at the end. It is right when only the final state matters: search-as-you-type, autosave, resize handlers that recompute a layout. It is wrong for anything needing intermediate feedback, because during continuous input it produces no calls at all.
Full entry →Throttle
you let the scroll handler run at most once every hundred milliseconds no matter how fast the events arrive.
Capping how often a function may run, so a continuous stream of events produces calls at a steady rate rather than one at the end. It is right when intermediate values matter: scroll position, drag coordinates, progress reporting. The trade against debouncing is exactly that — throttling gives you regular but partial updates, debouncing gives you one complete one, late.
Full entry →