Skip to content

Instantly share code, notes, and snippets.

@maoosi
Last active April 12, 2016 01:01
Show Gist options
  • Save maoosi/dd20ba8de06c336141f3 to your computer and use it in GitHub Desktop.
Save maoosi/dd20ba8de06c336141f3 to your computer and use it in GitHub Desktop.
Simple JavaScript debounce function - From Grafikart https://www.grafikart.fr/tutoriels/javascript/debounce-throttle-642
function debounce(callback, delay){
var timer;
return function(){
var args = arguments;
var context = this;
clearTimeout(timer);
timer = setTimeout(function(){
callback.apply(context, args);
}, delay)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment