Display or hide drawer with onClick
button.onclick = function() {


Use addEventListener instead. That way, you can add as many handlers as you want without replacing any previous ones assigned.

if (div.style.display !== 'block') {


Instead of using inline CSS, put them in stylesheets and define the styles in classes. Then have JS assign/remove classes instead to apply/remove. The problem is that 1) You have CSS in your JS and 2) inline CSS have very high specificity. The only way to override them is to replace the inline style value, or use !important on the stylesheet.

if(document.body.clientWidth &gt; 900) {


If you also use CSS, this can easily be remedied by media queries.

if(window.location.href.indexOf("home.php") &gt; -1) {


You probably want to use a more robust routing library like Page.js to do this.