var timer = null; $(window).resize(function () { if(timer) { clearTimeout(timer) } else { setTimeout(mediaScreen, 500); } });