attach event on window resize code example Example: add event listener on width screen resize window.addEventListener('resize', reportWindowSize);