Is not another face meng force of the problem ang! A little analysis, concise, clear thinking, no procrastination.

1. Load the outline of the answer process

  • The browser tool DNS server obtains the IP address of the domain name
  • Send an HTTP request to the machine at this IP
  • The server receives the HTTP request, processes it, and returns it
  • The browser gets what’s returned

2. Analyze the process

  • For example, when we enter https:////baidu.com in the browser, the NDS parse baiduXX.com first. The corresponding IP address of baiduXX.com is 1010.20002. The browser then sends an HTTP request to the IP
  • The server receives the HTTP request, evaluates it (pushes different content to different users), and returns the request (which returns a bunch of HTML strings), because only HTML is parsed by the browser, which is a W3C standard

3. Rendering process, focus!

– Generate DOM tree according to HTML structure – generate CSS tree according to CSS – integrate DOM tree and CSS tree to form RenderTree – start rendering and display according to RenderTree – execute and block rendering when script is encountered

Why put CSS in the HTML header?

In this way, the browser will get the CS as soon as possible and generate the CSS tree as soon as possible. Then after parsing the HTML, RendTree can be generated once and rendered once. If CSS is placed at the bottom, rendering will be delayed, affecting performance

Why put JS in the HTML header?

In addition, if 2JS execution involves DOM manipulation, it has to wait until DOM parsing is completed. When 3JS execution is placed at the bottom, HTML must be executed into DOM structure. If 4JS is placed at the top of HTML, Javascript is executed before the HTML is converted to a DOM structure, which may cause an error.

Brief process supplement?

1. The browser generates CSS tree, and then integrates DOM tree and CSS tree into RenderTree, and then renders RenderTree. With DOM structure and style, the rendering conditions are met.