Skip to content

Instantly share code, notes, and snippets.

@gopeter
Created September 24, 2013 14:35

Revisions

  1. Peter Göbel created this gist Sep 24, 2013.
    11 changes: 11 additions & 0 deletions new_gist_file
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    function throttle( fn, time ) {
    var t = 0;
    return function() {
    var args = arguments, ctx = this;
    clearTimeout(t);

    t = setTimeout( function() {
    fn.apply( ctx, args );
    }, time );
    };
    }