I was reading a book today and saw the loading and execution of html, css, and js. I found that I didn’t really understand it. I searched online for half an hour and still couldn’t figure it out. At this time, I found a passage that made me suddenly realize it, as follows :
HTML page loading and parsing process
1. The user enters the URL (assuming it is an HTML page and it is the first visit), the browser sends a request to the server, and the server returns the HTML file.
2. The browser starts loading the html code and finds that there is a tag in the
tag that refers to an external CSS file.3. The browser sends a request for the CSS file again, and the server returns the CSS file.
4. The browser continues to load the code of the
part of the html, and the CSS file has been obtained, and the page can be rendered.5. The browser finds an tag in the code that references an image and sends a request to the server. At this time, the browser will not wait until the image is downloaded, but will continue to render the subsequent code.
6. The server returns the image file. Since the image occupies a certain area and affects the arrangement of subsequent paragraphs, the browser needs to go back and re-render this part of the code.
7. The browser finds a