Overview

This page is the atomic definition. Rate limiting at the API layer (server-side throttling) is a distinct concept covered in fastapi.

Definition

Throttling enforces that a function executes at most once per defined time interval, no matter how many times it is called. If calls arrive more frequently than the interval, the extra calls are dropped (or queued, depending on implementation). Unlike debouncing, which waits for a quiet period, throttling fires the function immediately on the first call and then suppresses subsequent calls until the interval expires. This makes throttling the right choice for scroll event handlers and window resize listeners where you want continuous updates at a controlled rate rather than waiting for the user to stop. requestAnimationFrame is a specialized form of throttling that aligns execution with the browser’s paint cycle (approximately every 16 ms at 60 fps). Lodash provides _.throttle(fn, ms). API rate limiting on servers is a conceptually related but mechanically different use of the word: it limits the number of requests a client can make per time window at the network layer, not in JavaScript.

When it applies

Use throttling for: scroll position listeners, window resize handlers, mouse move tracking, and any high-frequency DOM event where you need regular intermediate feedback at a capped rate. Use debouncing when you only care about the final state after the event stream ends.

Example

function onScroll() {
  updateStickyHeader(window.scrollY);
}
const throttledScroll = _.throttle(onScroll, 100); // max 10 times/sec
window.addEventListener("scroll", throttledScroll);
// Even if scroll fires 60 times/sec, the handler runs at most every 100 ms.
  • debouncing - delays until quiet; use when only the final event matters.
  • react - scroll and resize handlers in React components need throttling to avoid excessive re-renders.
  • inp - throttling prevents jank from high-frequency event handlers.
  • web-vitals - scroll-linked animations that update too frequently degrade CLS and INP.

Citing this term

See Throttling (llmbestpractices.com/glossary/throttling).