title: When does parsing HTML DOM tree happen?
body: <p>I always see a rendering flow for a web page like the following image shows:
  <a href="https://i.stack.imgur.com/kBF3j.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kBF3j.png" alt="enter image description here"></a></p>
  
  <p>So the painting only begins after DOM tree is parsed and CSSOM is created, right? Another saying is, putting <code>&lt;script&gt;</code> in the end of <code>&lt;body&gt;</code> is the best practice so that the page renders something before script is downloaded.</p>
  
  <p>My question is, when does parsing DOM tree happens and how can we say it is done? In my understanding, <code>&lt;script&gt;</code> in the end is also <em>part of DOM tree</em>, and only if the script loaded can we call the DOM tree is created. The browser reads the html file from top to bottom, creating the DOM Tree and when it sees a <code>&lt;script&gt;</code>, it stops to download and execute it until the parse goes through the whole page. Or, does the page paints the page at the same time of parsing DOM tree?</p>