search
HomeWeb Front-endHTML TutorialThe order in which browsers load and render html

The order in which browsers load and render html

May 24, 2017 am 09:14 AM
htmlPage loading

The order in which browsers load and render HTML, how to speed up HTML page loading, HTML page loading and parsing processes, etc., will be introduced in detail in this article. Interested friends should not miss it

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. of.

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 semantic interpretive 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 those that have been rendered before) will be re-rendered.

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

Loading of JS

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

2. When references JS, 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 it is very likely that there is

code in JS that directly changes the DOM tree structure, such as using document.write or append Child, or even directly use location.href to 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 Presentation.

How to speed up HTML page loading

1. Page weight loss:

a. The fatness and thinness 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 own 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 reduce external JavaScript, CSS, images and other resource references, the less the use of different domain names, the better.

4. CacheReuse 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, video 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 performing operations such as "error correction" 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 p. 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 re-layout. Work.

b. This not only speeds up the display of the page, but also prevents some inappropriate changes in the layout 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), the browser sends a request to the server, and the server returns an html file.

2. The browser starts loading the html code and finds that there is a tag inside the head> 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 The order in which browsers load and render html tag in the code that references an image and makes 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> in the code (style.<a href="http://www.php.cn/wiki/927.html" target="_blank">display=”none”). Oops, suddenly such an element is missing, and the browser has to re-render this part of the code. <br/><br/>9. Finally waited for the arrival of , and the browser burst into tears... <br/><br/>10. Wait, it’s not over yet, the user clicked "Skin Change" in the interface "<a href="http://www.php.cn/code/5991.html" target="_blank">Button, Javascript allows the browser to change the CSS path of the <link> tag. <br/><br/>11. The browser summoned everyone present, "Everyone pack your bags, we have to start over...", browse The server requests a new CSS file from the server and re-renders the page. <p>【Related recommendations】<p>1. <a href="http://www.php.cn/course/list/11.html" target="_self">Html free video tutorial<p>2. <a href="http://www.php.cn/div-tutorial-362996.html" target="_self">html achieves a fixed table around and can scroll up, down, left and right<p>3. <a href="http://www.php.cn/div-tutorial-362995.html" target="_self">Detailed explanation of HTML tags commonly used in front-end development<p>4. <a href="http://www.php.cn/div-tutorial-362994.html" target="_self">Pure html code to complete the scrolling effect through the marquee tag <p>5. <a href="http://www.php.cn/div-tutorial-363090.html" target="_self">htmlDetailed explanation of examples of using Mailto to implement email sending function</script>

The above is the detailed content of The order in which browsers load and render html. For more information, please follow other related articles on the PHP Chinese website!

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
From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Is HTML easy to learn for beginners?Is HTML easy to learn for beginners?Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is an example of a starting tag in HTML?What is an example of a starting tag in HTML?Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

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)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

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.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

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

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)