JS:
function getScrollWidth() {
var scrollDiv = document.createElement('div');
scrollDiv.className = 'helper-scrollbar-width';
document.body.appendChild(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
return scrollbarWidth;
}
CSS:
.helper-scrollbar-width {
position: absolute;
top: -9999px;
width: 100px;
height: 100px;
overflow: scroll;
}