Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimmobrunfeldt/905261a9fa96f640182c to your computer and use it in GitHub Desktop.
Save kimmobrunfeldt/905261a9fa96f640182c to your computer and use it in GitHub Desktop.
Example of using Underscore's _.debounce function
// Example of using Underscore's _.debounce function
// debounce is useful for situations where you get multiple events fired
// from one action. For example resize event is sent multiple times when
// window is resized
var reloadIfResizeChange = _.debounce(function() {
window.location.reload();
}, 200);
window.addEventListener('resize', reloadIfResizeChange);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment