Skip to content

Instantly share code, notes, and snippets.

@jahilldev
Last active July 28, 2022 17:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jahilldev/4e8f2bd2bbb03edc47c4b3fa70f556eb to your computer and use it in GitHub Desktop.
Save jahilldev/4e8f2bd2bbb03edc47c4b3fa70f556eb to your computer and use it in GitHub Desktop.
Tiny JavaScript debounce function
function debounce(callback, frequency = 250, timer = null) {
return (...args) => (
clearTimeout(timer), (timer = setTimeout(callback, frequency, ...args))
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment