title: Should I use IIFE or window onload to initialize?
body: <p>Both of the following code snippets worked:</p>
  <p>Using IIFE in js file:</p>
  <pre><code>(function initialize() {
    txtInput = document.getElementById('txtInput');
    txtResult = document.getElementById('txtResult');
  
    txtInput.value = &quot;0&quot;;
    txtResult.value = &quot;0&quot;;
  
  }());
  </code></pre>
  <p>Calling <code>initialize()</code> on window load event in html file:</p>
  <pre><code>window.addEventListener('load', initialize, false);
  </code></pre>
  <p>Is one a better approach than other; in terms of performance or otherwise? As it stands right now, I am leaning more towards adding event listener to the window object, because it is more readable.</p>