var scrollbarSize;

function getScrollbarSize() {
  if (typeof scrollbarSize !== 'undefined') return scrollbarSize;

  var dummyScroller = document.createElement('div');
  dummyScroller.setAttribute('style', 'width:99px;height:99px;'
    + 'position:absolute;top:-9999px;overflow:scroll;');
  document.body.appendChild(dummyScroller);
  scrollbarSize = dummyScroller.offsetWidth - dummyScroller.clientWidth;
  document.body.removeChild(dummyScroller);
  return scrollbarSize;
}

function hasScrollbar() {
  return document.body.scrollHeight > window.innerHeight;
}

function on(options) {
  var rightPad = parseInt(getComputedStyle(document.body)['padding-right'], 10);
  var originalStyle = document.body.getAttribute('style') || '';
  originalStyle += 'overflow:hidden;';
  if (hasScrollbar()) {
    rightPad += getScrollbarSize();
    originalStyle += 'padding-right:' + rightPad + 'px;';
  }
  document.body.setAttribute('style', originalStyle);
}

function off() {
  var cleanedStyle = document.body.getAttribute('style')
    .replace(/overflow:hidden;(?:padding-right:.+?;)?/, '');
  document.body.setAttribute('style', cleanedStyle);
}

module.exports = {
  on: on,
  off: off,
};

@@ -11,16 +11,52 @@
 barSize;
+%0Avar doc = document.documentElement;
 %0A%0Afuncti
@@ -325,26 +325,16 @@
 );%0A  doc
-ument.body
 .appendC
@@ -432,26 +432,16 @@
 h;%0A  doc
-ument.body
 .removeC
@@ -526,26 +526,16 @@
 turn doc
-ument.body
 .scrollH
@@ -634,26 +634,16 @@
 tyle(doc
-ument.body
 )%5B'paddi
@@ -680,34 +680,24 @@
 lStyle = doc
-ument.body
 .getAttribut
@@ -876,34 +876,24 @@
 ';%0A  %7D%0A  doc
-ument.body
 .setAttribut
@@ -963,26 +963,16 @@
 le = doc
-ument.body
 .getAttr
@@ -1056,18 +1056,8 @@
  doc
-ument.body
 .set

Switch inline styles from body to documentElement