// create an element with the scroll, but without borders and paddings.let div =newElement('div', (self) => {self.style.overflowY ='scroll';self.style.width ='50px';self.style.height ='50px';self.style.background ='#999';self.innerText ='xxx '.repeat(50);// must put it in the document, otherwise sizes will be 0document.body.append(self);});// scrollbar widthlet scrollbarWidth =div.offsetWidth -div.clientWidth;