title: Is innerHTML asynchronous?
body: <p>I hope I won't make a fool of myself but I'm trying to understand what is happening in those two lines of code:</p>
  
  <pre><code>document.body.innerHTML = 'something';
  alert('something else');
  </code></pre>
  
  <p>What I am observing is that alert shows before HTML has been updated (or maybe it has but the page hasn't been refreshed/repainted/whatever)</p>
  
  <p>Checkout this <a href="http://codepen.io/anon/pen/NpzqQJ" rel="noreferrer">codepen</a> to see what I mean.</p>
  
  <p>Please note that even putting <code>alert</code> in <code>setTimeout(..., 0)</code> does not help. Looks like it takes more event loops for <code>innerHTML</code> to actually update page. </p>
  
  <p>EDIT:</p>
  
  <p>I forgot to mention I am using Chrome and did not check other browsers. Looks like it's only visible in Chrome. Nevertheless I am still interested why is that happening.</p>