Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A small library which allows functions to be "debounced"
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/jasmine-1.3.1
spec
src
MIT.LICENSE
README.md
SpecRunner.html
index.html

README.md

DebouncerJS

A small library which allows functions to be "debounced". This provides a convenience method for decreasing "chatter" for potentially frequent function calls. This can be especially useful for events fired when an onkeyup event fires, for instance, to avoid several AJAX calls from an HTML page.

Example

The window object's resize event fires very frequently in IE. This can cause performance problems. Use the debouncer library to improve perceived performance. This example uses jQuery.

var windowResize = function() {
    /* processing here */
};

var debouncedWindowResize = debounce(windowResize, 200);

$(window).resize(debouncedWindowResize);

or more concisely,

$(window).resize(debounce(function() {
    /* processing here */
}, 200));
Something went wrong with that request. Please try again.