Skip to content

Instantly share code, notes, and snippets.

@the-fejw
Created November 13, 2020 09:14
Show Gist options
  • Save the-fejw/2b7ec4aa2acda6420cbf7d7a73801226 to your computer and use it in GitHub Desktop.
Save the-fejw/2b7ec4aa2acda6420cbf7d7a73801226 to your computer and use it in GitHub Desktop.
js throttle source example
function throttle(fn, wait) {
let timer = false;
return function() {
if (!timer) {
fn.apply(this, arguments);
timer = setTimeout(() => {
clearTimeout(timer);
timer = false;
}, wait);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment