The following code show how to get the width and height of the window in px:
const windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
Source
https://www.javascripttutorial.net/dom/css/get-the-width-and-height-of-the-window/