title: Trying to execute two JavaScript files together with window.onload
body: <p>I've got two separate JavaScript files linked to one HTML document and when I run it, it seems the second JS file overrides the first. I think it has to do with the window.onload being called in each file but am not sure how to work around that. </p>
  
  <p>I've tried using window.onloadend on one of the JS files and window.onload on the other but with the same results, the window.onloadend is the only file that is executed.</p>
  
  <p>file1.js</p>
  
  <pre><code>function init() {
      applyFunction();
      prefillForm();
      var applyForm = document.getElementById("applyForm");
      applyForm.onsubmit = validate;
  }
  
  window.onload = init;
  </code></pre>
  
  <p>file2.js </p>
  
  <pre><code>function init() {
      currentPage();
      timer();
  }
  
  window.onload = init;
  </code></pre>