(function(document) {

  document.addEventListener("wheel", function(e) {
    if (e.shiftKey) {
      if (e.deltaX > 0) {
        window.history.back();
        return e.preventDefault();
      } else if (e.deltaX < 0) {
        window.history.forward();
        return e.preventDefault();
      }
    }
  });
  
})(document);

document.addEventListener("wheel", function(e) {
  if (e.shiftKey && e.deltaX != 0) {
    window.history.go(-Math.sign(e.deltaX));
    return e.preventDefault();
  }
});

Make the code even shorter
Make the code even shorter
