Skip to content

Instantly share code, notes, and snippets.

@lkaczanowski
Created February 3, 2014 07:26
Show Gist options
  • Select an option

  • Save lkaczanowski/8780001 to your computer and use it in GitHub Desktop.

Select an option

Save lkaczanowski/8780001 to your computer and use it in GitHub Desktop.
JQuery Debounce
(function ($) {
'use strict';
$.debounce = function (delay, fn) {
var timer = null;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
fn.apply(context, args);
}, delay);
};
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment