In some of my personal apps, I've noticed that making an animation loop with requestAnimationFrame and detecting window size inside there then updating stuff seems to be smoother than relying on window.onresize (https://github.com/sfirrin/Clean-Google-Calendar/blob/master/main.js#L37).