Skip to content

Instantly share code, notes, and snippets.

@PickledDragon
Created August 31, 2015 17:01
Show Gist options
  • Save PickledDragon/cbd5ade4b6ecb3df281c to your computer and use it in GitHub Desktop.
Save PickledDragon/cbd5ade4b6ecb3df281c to your computer and use it in GitHub Desktop.
var NAME_FILTER_THROTTLE_DELAY = 350;// ms
function throttle(fn, delay) {
var timer = null;
return function () {
var context = this, args = arguments;
clearTimeout( timer );
timer = setTimeout( function(){ fn.apply( context, args ); }, delay );
};
}
//usage: throttle( eventHandlerName, NAME_FILTER_THROTTLE_DELAY );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment