Another onliner I love, that returns body scrollbar width. If scrollbar is not shown it will return zero (including mobile devices).
function getScrollbarWidth() {
return window.innerWidth - document.documentElement.clientWidth;
}
Click on the button to try it yourself:
Tested on:
Comments (5)