Created
August 14, 2012 14:44
-
-
Save derek-watson/3349917 to your computer and use it in GitHub Desktop.
Simple javascript function throttling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isThrottled = false, | |
throttleDuration = 24; // ms | |
function thingToThrottle() { | |
if (isThrottled) { return; } | |
isThrottled = true; | |
setTimeout(function () { isThrottled = false; }, throttleDuration); | |
// do your work here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's the kind of throttling I'm talking about.