Throttle
Also called: throttling, at most once per interval, rate-limit a handler.
Let something run at most once per time interval, however often it is triggered. Scroll events can fire dozens of times a second; throttled to 500 ms, the page saves your reading position only twice a second.
Scrolling fires about 30 events a second. The page saves your reading position; with throttle on it saves at most once every 500 ms while you keep scrolling.
Idle
Say it in a prompt
Throttle the scroll handler that saves reading progress to one call per 500 ms, on both the leading and trailing edge, sending PUT /api/articles/:id/progress with the percent read, so the last position is always saved when scrolling stops. Seen on
- Lodash: _.throttle makes a function run at most once every set number of milliseconds.
You might describe it as
- only save every half second while scrolling
- stop the scroll handler from running hundreds of times
- limit how often it fires while I keep moving
Not to be confused with
- Debounce
Throttle keeps firing at a steady pace while events continue; debounce waits until they stop and fires once.