Skip to content

Instantly share code, notes, and snippets.

@felipepodesta
Forked from DustinHigginbotham/jquery.debounce.js
Created September 20, 2019 01:45
Show Gist options
  • Select an option

  • Save felipepodesta/b0f360fcba6524fe7273f37a4a114393 to your computer and use it in GitHub Desktop.

Select an option

Save felipepodesta/b0f360fcba6524fe7273f37a4a114393 to your computer and use it in GitHub Desktop.
/**
* Usage:
*
* $.debounce(function() { alert('heyo'); }, 1000);
* $.debounce(function() { alert('heyo'); }, 1000);
* $.debounce(function() { alert('heyo'); }, 1000);
*/
jQuery.extend({
debounceInt: null,
debounce: function(fn, timeout) {
clearTimeout(jQuery.debounceInt);
jQuery.debounceInt = setTimeout(fn, timeout);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment