Skip to content

Instantly share code, notes, and snippets.

@sshmyg
Created January 31, 2017 20:27
Show Gist options
  • Save sshmyg/1be4c0b61a8aa38530180a56fab6d8e8 to your computer and use it in GitHub Desktop.
Save sshmyg/1be4c0b61a8aa38530180a56fab6d8e8 to your computer and use it in GitHub Desktop.
Difference between Debounce and Throttle

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle

Throttle a function when you want it to execute periodically with an interval in between each execution.
Example A user is typing into a field continuously for 30s but you want to make sure you capture a users input every 1s and perform an action.

Reference

debouncing-throttling-explained-examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment