Skip to content

Instantly share code, notes, and snippets.

@blainerobison
Last active December 30, 2015 04:49
Show Gist options
  • Save blainerobison/8151fb2c416cb83f6ee3 to your computer and use it in GitHub Desktop.
Save blainerobison/8151fb2c416cb83f6ee3 to your computer and use it in GitHub Desktop.
js: Delay execution on window resize
var resizeTimer;
// foo
function foo() {
console.log( 'delayed' );
}
// initially run foo
foo();
$(window).resize( function() {
clearTimeout( resizeTimer );
resizeTimer = setTimeout( function() {
// run foo with delay
foo();
}, 250 );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment