Skip to content

Instantly share code, notes, and snippets.

@xphere
Created February 17, 2014 15:59
Show Gist options
  • Select an option

  • Save xphere/9053239 to your computer and use it in GitHub Desktop.

Select an option

Save xphere/9053239 to your computer and use it in GitHub Desktop.
debounce.js
function debounce(callback, timeout) {
var timer;
return function() {
timer && clearTimeout(timer);
timer = setTimeout(function(args) {
timer = null;
callback.apply(this, args);
}.bind(this, arguments), timeout||100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment