Skip to content

Instantly share code, notes, and snippets.

@morbidcamel101
Created November 2, 2016 06:39
Show Gist options
  • Select an option

  • Save morbidcamel101/87d4519596f18fda651e0823c8ceddfb to your computer and use it in GitHub Desktop.

Select an option

Save morbidcamel101/87d4519596f18fda651e0823c8ceddfb to your computer and use it in GitHub Desktop.
Generic Throttling mecanism in Javascript
function throttle(f, delay)
{
var timer = null;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = window.setTimeout(function () {
f.apply(context, args);
},
delay || 500);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment