What is Throttle?
Allow a function to run at most once per time interval, ignoring the extra events.
Type a tool name, format or task
Allow a function to run at most once per time interval, ignoring the extra events. Interactive step-by-step animation with JavaScript code, complexity and front-end use cases.
Loading animation...
Allow a function to run at most once per time interval, ignoring the extra events. Remember when the function last ran. On each event, check whether the wait time has passed. If yes run it and update the time; if not ignore the event. Time complexity: O(1) per event. Space complexity: O(1). Scroll, mousemove, drag and resize handlers that must keep the UI responsive while still updating regularly.
Allow a function to run at most once per time interval, ignoring the extra events.
Time: O(1) per event. Space: O(1).
Scroll, mousemove, drag and resize handlers that must keep the UI responsive while still updating regularly.
No. This converter runs in your browser for ordinary use, so the input is not sent to a backend by this tool.
Keep working without searching again.
Now: 0 ms
A throttled function runs at most once every 300 ms. Events that arrive during the cooldown are ignored.
function throttle(fn, wait) {let last = 0;return (...args) => {const now = Date.now();if (now - last >= wait) {last = now;fn(...args);}};}
Tip: use the arrow keys to step and the space bar to play or pause.