Skip to content

Instantly share code, notes, and snippets.

@derek-watson
Created August 14, 2012 14:44

Revisions

  1. derek-watson created this gist Aug 14, 2012.
    10 changes: 10 additions & 0 deletions simple-throttle.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    var isThrottled = false,
    throttleDuration = 24; // ms

    function thingToThrottle() {
    if (isThrottled) { return; }
    isThrottled = true;
    setTimeout(function () { isThrottled = false; }, throttleDuration);

    // do your work here
    }