title: Two JS files with window.onload = function() are conflicting
body: <p>I had this script to open and close my side menu, it had an HTML built-in event handler. Then I read that built-in event handlers are old-fashioned. So I reworked it to pure JS.</p>
  <p>I made my own event handler, which should've worked, but it returned an error: Uncaught TypeError: Cannot set property 'onclick' of null.</p>
  <p>Then I read <a href="https://stackoverflow.com/questions/9778888/uncaught-typeerror-cannot-set-property-onclick-of-null">here</a> that maybe I should add to JS:</p>
  <pre><code>window.onload = function(){ 
      // your code 
  };
  </code></pre>
  <p>I added the function and it worked.</p>
  <p>But then it suddenly stopped working after I added another JS for an accordion with the same <code>window.onload</code> since it didn't want to work without the function or when <code>&lt;script&gt;</code> wasn't inside the <code>&lt;head&gt;</code>.</p>
  <p>I'm new to JS. Can you help me? Is it possible to make both js work without <code>window.onload</code> and keep them inside <code>&lt;head&gt;</code>?</p>