if(w < 1200){ //if var w = window.innerWidth; is smaller than 1200px then do this... }else{ //Normal function... }