var b; $(window).resize(function(){ window.clearTimeout(b); b = window.setTimeout(function () { alert(a) }, 20) })