search
HomeWeb Front-endHTML TutorialDetailed introduction to HTML page loading and parsing process_HTML/Xhtml_Web page production

The order in which the browser loads and renders HTML

1. The order of IE downloading is from top to bottom, and the order of rendering is also from top to bottom. Downloading and rendering are performed at the same time.

2. When rendering to a certain part of the page, all parts above it have been downloaded (this does not mean that all associated elements have been downloaded).

3. If you encounter a semantically interpretable tag embedded file (JS script, CSS style), then the IE download process will enable a separate connection for downloading.

4. After the style sheet is downloaded, it will be parsed together with all previously downloaded style sheets. After the parsing is completed, all previous elements (including previously rendered elements) will be re-rendered.

5. If there is redefinition in JS or CSS, the later-defined function will overwrite the previously-defined function.

JS loading

1. Cannot download and parse in parallel (blocking download).

2. When JS is referenced, the browser sends a js request and will wait for the return of the request. Because the browser needs a stable DOM tree structure, and there is likely to be

code in JS that directly changes the DOM tree structure, such as using document.write or appendChild, or even directly using location.href. Jump, in order to prevent JS from modifying the DOM tree

, the browser needs to rebuild the DOM tree, so it will block other downloads and renderings.

How to speed up HTML Page loading speed

1. Page weight loss:

a. The weight of the page is the most important factor affecting the loading speed.

b. Delete unnecessary spaces and comments.

c. Move the inline script and css to external files.

d. You can use HTML Tidy to lose weight for HTML, and you can also use some compression tools to lose weight for JavaScript.

2. Reduce the number of files:

a. Reducing the number of files referenced on the page can reduce the number of HTTP connections.

b. Many JavaScript and CSS files can be merged and are best merged. Caibangzi has merged its JavaScript. functions and Prototype.js into a base.js file.

3. Reduce domain name queries:

a. DNS query and domain name resolution are also time-consuming, so it is necessary to reduce the references to external JavaScript, CSS, images and other resources. The more different domain names are used, Less is better.

4. Cache reused data:

a. Cache reused data.

5. Optimize the loading order of page elements:

a. First load the content initially displayed on the page and the JavaScript and CSS related to it, then load HTML-related things, like what is not initially displayed Relevant pictures, flash, videos and other very fat resources are loaded last.

6. Reduce the number of inline JavaScript:

a. The browser parser will assume that inline JavaScript will change the page structure, so using inline JavaScript is more expensive.

b. Do not use document.write() to output content, use modern W3C DOM methods to handle page content for modern browsers.

7. Use modern CSS and legal tags:

a. Use modern CSS to reduce tags and images. For example, using modern CSS text can completely replace some images with only text.

b. Use legal tags to prevent the browser from doing "error correction" operations when parsing HTML. It can also be used by HTML Tidy to slim down HTML.

8. Chunk your content:

a. Do not use nested tables, but use non-nested tables or divs. Break the layout based on a large nested table into multiple small tables, so that there is no need to wait until the entire page (or large table) content is loaded before displaying it.

9. Specify the size of images and tables:

a. If the browser can immediately determine the size of the image or table, then it can display the page immediately without having to redo some layout arrangements. Work.

b. This not only speeds up the display of the page, but also prevents some inappropriate layout changes after the page is loaded.

c. image uses height and width.

HTML page loading and parsing process

1. The user enters the URL (assuming it is an HTML page and it is the first visit), and the browser sends a request to the server. The server returns the html file.

2. The browser starts loading the html code and finds that there is a tag inside the tag that references 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 a Detailed introduction to HTML page loading and parsing process_HTML/Xhtml_Web page production 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 <script> tag containing a line of Javascript code and runs it quickly. <br /><br />8. The Javascript script executes this statement, which instructs the browser to hide a certain <style> (style.display="none") in the code. Oops, suddenly such an element is missing, and the browser has to re-render this part of the code. <br /><br />9. Finally waiting for the arrival of , the browser burst into tears... <br /><br />10. Wait, it’s not over yet, the user clicked the "Skin Change" button in the interface , Javascript allows the browser to change the CSS path of the <link> tag. <br /><br />11. The browser summons everyone <div><span><ul><li>, "Everyone pack your bags, we have to start over...", the browser requests the server Create a new CSS file and re-render the page.</script>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML超文本标记语言--超在那里?(文档分析)HTML超文本标记语言--超在那里?(文档分析)Aug 02, 2022 pm 06:04 PM

本篇文章带大家了解一下HTML(超文本标记语言),介绍一下HTML的本质,HTML文档的结构、HTML文档的基本标签和图像标签、列表、表格标签、媒体元素、表单,希望对大家有所帮助!

html和css算编程语言吗html和css算编程语言吗Sep 21, 2022 pm 04:09 PM

不算。html是一种用来告知浏览器如何组织页面的标记语言,而CSS是一种用来表现HTML或XML等文件样式的样式设计语言;html和css不具备很强的逻辑性和流程控制功能,缺乏灵活性,且html和css不能按照人类的设计对一件工作进行重复的循环,直至得到让人类满意的答案。

web前端笔试题库之HTML篇web前端笔试题库之HTML篇Apr 21, 2022 am 11:56 AM

总结了一些web前端面试(笔试)题分享给大家,本篇文章就先给大家分享HTML部分的笔试题(附答案),大家可以自己做做,看看能答对几个!

总结HTML中a标签的使用方法及跳转方式总结HTML中a标签的使用方法及跳转方式Aug 05, 2022 am 09:18 AM

本文给大家总结介绍a标签使用方法和跳转方式,希望对大家有所帮助!

HTML5中画布标签是什么HTML5中画布标签是什么May 18, 2022 pm 04:55 PM

HTML5中画布标签是“<canvas>”。canvas标签用于图形的绘制,它只是一个矩形的图形容器,绘制图形必须通过脚本(通常是JavaScript)来完成;开发者可利用多种js方法来在canvas中绘制路径、盒、圆、字符以及添加图像等。

html中document是什么html中document是什么Jun 17, 2022 pm 04:18 PM

在html中,document是文档对象的意思,代表浏览器窗口的文档;document对象是window对象的子对象,所以可通过“window.document”属性对其进行访问,每个载入浏览器的HTML文档都会成为Document对象。

html5废弃了哪个列表标签html5废弃了哪个列表标签Jun 01, 2022 pm 06:32 PM

html5废弃了dir列表标签。dir标签被用来定义目录列表,一般和li标签配合使用,在dir标签对中通过li标签来设置列表项,语法“<dir><li>列表项值</li>...</dir>”。HTML5已经不支持dir,可使用ul标签取代。

Html5怎么取消td边框Html5怎么取消td边框May 18, 2022 pm 06:57 PM

3种取消方法:1、给td元素添加“border:none”无边框样式即可,语法“td{border:none}”。2、给td元素添加“border:0”样式,语法“td{border:0;}”,将td边框的宽度设置为0即可。3、给td元素添加“border:transparent”样式,语法“td{border:transparent;}”,将td边框的颜色设置为透明即可。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.