var removeExcessSpaces = function(htmlString) {
	var processedString = htmlString.replace(/\s+</g, '<');
	processedString = processedString.replace(/>\s+/g, '>');
  processedString = processedString.replace(/_/g, ' ');
	return processedString;
}

var ready = function(fn) {
  if(document.readyState != 'loading') {
    fn();
  }
  else {
    document.addEventListener('DOMContentLoaded', fn);
  }
}
ready(function() {
	document.querySelector('body').innerHTML = removeExcessSpaces(document.querySelector('body').innerHTML);

  new Controller();
});

var removeExcessSpaces = function(selector) {
  var htmlString = document.querySelector(selector).innerHTML;
	htmlString = htmlString.replace(/\s+</g, '<');
	htmlString = htmlString.replace(/>\s+/g, '>');
  htmlString = htmlString.replace(/_/g, ' ');
  document.querySelector(selector).innerHTML = htmlString;
}

var ready = function(fn) {
  if(document.readyState != 'loading') {
    fn();
  }
  else {
    document.addEventListener('DOMContentLoaded', fn);
  }
}
ready(function() {
  removeExcessSpaces('main');

  new Controller();
});

Update removeExcessSpaces to operate with side effects
Update removeExcessSpaces to operate with side effects
