Skip to content

Instantly share code, notes, and snippets.

@jzaefferer
Created October 19, 2011 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jzaefferer/1298986 to your computer and use it in GitHub Desktop.
Save jzaefferer/1298986 to your computer and use it in GitHub Desktop.
Function.prototype.debounce = function(threshold) {
threshold = threshold || 100;
var func = this;
var timeout;
return function() {
var obj = this,
args = arguments;
clearTimeout(timeout);
timeout = setTimeout(function() {
func.apply(obj, args);
}, threshold);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment