A lightweight, dependency-free JavaScript module for debouncing functions based on David Walsh's debounce function.
- Dependency-free
- AMD/CommonJS module support
javascript-debounce is also really tiny:
Uncompressed | 909 bytes |
---|---|
Minified | 664 bytes |
Minified and gzipped | 406 bytes |
Adding javascript-debounce to your project is easy! You've got a couple options:
- Download a tagged version from GitHub and do it yourself (old school).
- Install via Bower:
bower install javascript-debounce
- Install via npm:
npm install javascript-debounce
Type: Function
A function to be executed after delay
milliseconds.
Type: Number
The delay, in milliseconds, after the final event invokation at which time callback
will be fired.
if ('addEventListener' in window) {
var handleResize = debounce(function() {
console.log('This method fired 250ms after the resize event was last invoked.');
}, 250);
window.addEventListener('resize', handleResize);
}
javascript-debounce is based on David Walsh's code and article JavaScript Debounce Function. His site is an invaluable resource for Web developers.
javascript-debounce is written and maintained by Jason Garber with the help of some great contributors.
javascript-debounce is freely available under The MIT License. Go forth and make the Web a more accessible place.