当前位置:网站首页>Browser rendering principle and rearrangement and redrawing
Browser rendering principle and rearrangement and redrawing
2022-07-05 16:56:00 【Love to paddle de whale brother ~】
Browser rendering principle
Browser rendering is divided into five stages .
The first stage :HTML analysis --> DOM Trees
Browsers cannot directly understand HTML file , First, analyze it , And in the process of parsing, send various external resource requests for page rendering DOM Trees .
The second stage : CSS analysis --> CSSOM Trees
Similarly, browsers can also directly understand CSS Code , Need to identify and load CSS The code is processed into what you understand CSSOM Trees .
The third stage : Style and structure merge --> Render tree
The browser will DOM Trees and CSSOM Trees are combined to generate rendering trees (:after :before And other pseudo elements will be built to DOM In the tree ).
Render tree features : Contains only the nodes needed to render the web page .
The process of building a rendering tree
- First step : from DOM The root node of the tree starts traversing , Filter out all visible nodes ;
- The second step : Match visible nodes CSSOM Trees ;
The fourth stage : The page layout --> Layout rendering tree
The browser traverses the rendering tree , Write the nested relationship between elements into the document flow box model in the form of box model , And calculate the exact size and location of the elements in the layout process . After the calculation , Write the corresponding information back to the rendering tree to form “ Layout rendering tree ”.
The fifth stage : Page drawing --> Display page
At this stage, the browser finally gets all the information about drawing the page , Convert every node in the rendering tree into visible pixels , Finally, the page will be presented in front of us .
rearrangement
When we modify DOM Width of node 、 High or hidden , The browser needs to recalculate the geometric attributes of nodes , Then the process of plotting the results of the calculation is called rearrangement ( It's also called backflow ).
Browser rearrangement process

Conditions triggering rearrangement
- change DOM Tree structure : The increase or decrease of nodes 、 Mobile, etc
- Get some through " Instant Computing " Get the attribute of the value :offsetWidth、offsetHeight、offsetTop、offsetLeft、 scrollTop、scrollLeft、scrollWidth、scrollHeight、clientTop、clientLeft、clientWidth、clientHeight And call getComputedStyle Method , perhaps IE Of currentStyle Method .
Repaint
When we modify DOM The style of ( Does not affect its geometric properties ) when , Browsers need to redraw new styles for elements. The process is called redrawing .
Browser redrawing process

Conditions that trigger redrawing
modify DOM The style of , But without affecting its geometric attributes, redrawing will occur .
Optimize
Rearrangement and redrawing are more performance consuming , So in the development process , We should be Avoid rearrangement and reduce redrawing .
This concludes the article
If you have any other ideas , Welcome to the comment area !
边栏推荐
- Benji Banas membership pass holders' second quarter reward activities update list
- [js] 技巧 简化if 判空
- Combined use of vant popup+ other components and pit avoidance Guide
- Etcd build a highly available etcd cluster
- Hiengine: comparable to the local cloud native memory database engine
- Global Data Center released DC brain system, enabling intelligent operation and management through science and technology
- 齐宣王典故
- Android privacy sandbox developer preview 3: privacy, security and personalized experience
- Benji Bananas 会员通行证持有人第二季奖励活动更新一览
- DenseNet
猜你喜欢

Solve cmakelist find_ Package cannot find Qt5, ECM cannot be found

How does win11 change icons for applications? Win11 method of changing icons for applications

Accès aux données - intégration du cadre d'entité

如何安装mysql

The two ways of domestic chip industry chain go hand in hand. ASML really panicked and increased cooperation on a large scale

Flet tutorial 12 stack overlapping to build a basic introduction to graphic and text mixing (tutorial includes source code)

Cs231n notes (bottom) - applicable to 0 Foundation

How to uninstall MySQL cleanly

Binary tree related OJ problems

二叉树相关OJ题
随机推荐
American chips are no longer proud, and Chinese chips have successfully won the first place in emerging fields
Flet教程之 12 Stack 重叠组建图文混合 基础入门(教程含源码)
Jarvis OJ shell流量分析
sqlserver 做cdc 要对数据库性能有什么要求么
Binary tree related OJ problems
文件操作--I/O
Data access - entityframework integration
[echart] resize lodash 实现窗口缩放时图表自适应
Android privacy sandbox developer preview 3: privacy, security and personalized experience
[61dctf]fm
[729. My Schedule i]
[es6] 模板字符串内添加if判断或添加三元运算符判断
China Radio and television officially launched 5g services, and China Mobile quickly launched free services to retain users
拷贝方式之DMA
[deep learning] [original] let yolov6-0.1.0 support the txt reading dataset mode of yolov5
[team PK competition] the task of this week has been opened | question answering challenge to consolidate the knowledge of commodity details
How to uninstall MySQL cleanly
网站页面禁止复制内容 JS代码
齐宣王典故
C# TCP如何设置心跳数据包,才显得优雅呢?