Skip to content

Instantly share code, notes, and snippets.

@edgebal
Created July 29, 2015 15:02
Show Gist options
  • Save edgebal/5a12e1f669640c131c3f to your computer and use it in GitHub Desktop.
Save edgebal/5a12e1f669640c131c3f to your computer and use it in GitHub Desktop.
// begin http://sampsonblog.com/749/simple-throttle-function
var throttle = function(callback, limit) {
var wait = false; // Initially, we're not waiting
return function () { // We return a throttled function
if (!wait) { // If we're not waiting
callback.call(); // Execute users function
wait = true; // Prevent future invocations
win.setTimeout(function () { // After a period of time
wait = false; // And allow future invocations
}, limit);
}
}
}
// end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment