Skip to content

Instantly share code, notes, and snippets.

@jrainlau
Created August 8, 2016 01:47
Show Gist options
  • Save jrainlau/392b35a255742e9f00785dfa079ff583 to your computer and use it in GitHub Desktop.
Save jrainlau/392b35a255742e9f00785dfa079ff583 to your computer and use it in GitHub Desktop.
function throttling
var throttle = function(fn, delay){
var timer = null;
return function(){
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function(){
fn.apply(context, args);
}, delay);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment