throttle function is cool

2007-12-03 @ 14:20#

ncz has a great utility function for javascript called throttle(). it allows you to limit the number of times a selected method can be called within a time interval. a way to 'throttle' your code to prevent races and other bottlenecks. sweet!

function throttle(method, scope) {
      clearTimeout(method._tId);
      method._tId= setTimeout(function(){
          method.call(scope);
      }, 100);
  }

code