window.onresize = function() { if (window.innerHeight >= 820) { /* ... */ } if (window.innerWidth <= 1280) { /* ... */ } }