QuizNot attempted
Debounce or throttle?
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- Throttle: you want regular updates DURING the scroll
- Throttle runs at most once per N ms while events keep coming, so the button updates regularly DURING the scroll.
- Not debounce: fires only after scrolling stops, so the button lags.
- Not setInterval: polls even when nothing scrolls.
- Not debounce 0ms: still waits for a pause in events, it just fires right after it.
- For visibility toggles, an IntersectionObserver on a sentinel is often better than both.