title: it takes long time when i run javascript before window.onload
body: <p>I have the code for counting from 1 to n.</p>
  
  <p>The following code it takes about 1s.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const maxNum = Math.pow(2, 26);
  const startTime = performance.now();
  let result = 0;
  for(let i = 1; i &lt;= maxNum; i++) {
      result += i;
  }
  console.log(performance.now() - startTime);</code></pre>
  </div>
  </div>
  </p>
  
  <p>But, once i put the same scripts in the window.onload, it takes about 65ms. Why the big difference?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>window.onload = function() {
      const maxNum = Math.pow(2, 26);
      const startTime = performance.now();
      let result = 0;
      for(let i = 1; i &lt;= maxNum; i++) {
          result += i;
      }
      console.log(performance.now() - startTime);
  };</code></pre>
  </div>
  </div>
  </p>