Skip to content

Instantly share code, notes, and snippets.

@ottonascarella
Created June 26, 2016 06:11
Show Gist options
  • Save ottonascarella/c874af2d3419a350772eaf05ec438135 to your computer and use it in GitHub Desktop.
Save ottonascarella/c874af2d3419a350772eaf05ec438135 to your computer and use it in GitHub Desktop.
Function debouncing Vanilla JS
Function.prototype.debounce = function(delay) {
var outter = this,
timer;
return function() {
var inner = this,
args = [].slice.apply(arguments);
clearTimeout(timer);
timer = setTimeout(function() {
outter.apply(inner, args);
}, delay);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment