debounce

This function debounces events that fire in rapid succession to a specified timeout value so the event is effectively fired only at the specified timeout rather than continuously.

Use this useful function for debouncing frequent UI events for things like window.resize() or element.ondrag() which fire frequently.

// fire resize event only every 50ms
var resizeHandler = debounce(function() { /* do something */,50);
$(window).resize(resizeHandler);

debounce(func,wait,immediate)

Parameters

func
The function that is to be debounced.

wait
The wait interval at which time the debounced function is called.

immediate
if true, func passed is immediately called


© West Wind Technologies, 1996-2016 • Updated: 12/12/15
Comment or report problem with topic