function initBodySize() {
    let rule1 = `body::before {
         content: "Width: " attr(data-width) " / Height: " attr(data-height);
         position: fixed;
         top: 0;
         right: 0;
         padding: 2rem;
         color: red;
         font-size: 1.5rem;
         font-weight: bold;
    }`;
    document.styleSheets[0].insertRule(rule1, document.styleSheets[0].rules.length)
}

function updateBodySize() {
    var body = document.querySelector('body');
    body.setAttribute('data-width', window.innerWidth);
    body.setAttribute('data-height', window.innerHeight);
}

window.addEventListener('resize', updateBodySize);
initBodySize();
setTimeout(updateBodySize,50);
