bindWithDelay jQuery Plugin (see example)

The Basics

What is the difference between throttling and not?

Imagine you are scrolling down a long page for 3 seconds and you have bindWithDelay running with a timeout of 1000ms. By default, your event will only fire a second after you have completely finished scrolling. If you have the optional throttling on, it will fire once per second during the scrolling - a total of 3 times instead of 1. Move your mouse around in circles and look at the example below to see:

A Simple Example

As you have been on this page, it has been tracking how many times your browser's mousemove, click, scroll, and resize events have fired (both with and without bindWithDelay). Go ahead and move your mouse around and click (try clicking a bunch of times in a row to see what it does) , or resize your browser to get a look at how it works.

$(document).bind("mousemove") has been called: 0 times.
$(document).bindWithDelay("mousemove", 1000) has been called: 0 times.
$(document).bindWithDelay("mousemove", 1000, true) has been called: 0 times.
$(document).bind("click") has been called: 0 times.
$(document).bindWithDelay("click", 1000) has been called: 0 times.
$(document).bindWithDelay("click", 1000, true) has been called: 0 times.
$(document).bind("scroll") has been called: 0 times.
$(document).bindWithDelay("scroll", 1000) has been called: 0 times.
$(document).bindWithDelay("scroll", 1000, true) has been called: 0 times.
$(window).bind("resize") has been called: 0 times.
$(window).bindWithDelay("resize", 1000) has been called: 0 times.
$(window).bindWithDelay("resize", 1000, true) has been called: 0 times.