当前位置:网站首页>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 !
边栏推荐
- Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
- Win11提示无法安全下载软件怎么办?Win11无法安全下载软件
- American chips are no longer proud, and Chinese chips have successfully won the first place in emerging fields
- [深度学习][原创]让yolov6-0.1.0支持yolov5的txt读取数据集模式
- 【刷题篇】有效的数独
- Etcd build a highly available etcd cluster
- Facing new challenges and becoming a better self -- attacking technology er
- 拷贝方式之DMA
- [61dctf]fm
- 深耕5G,芯讯通持续推动5G应用百花齐放
猜你喜欢
Flet教程之 11 Row组件在水平数组中显示其子项的控件 基础入门(教程含源码)
BS-XX-042 基于SSM实现人事管理系统
Enter a command with the keyboard
有序链表集合求交集 方法 总结
Desci: is decentralized science the new trend of Web3.0?
Seaborn draws 11 histograms
Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
Fleet tutorial 09 basic introduction to navigationrail (tutorial includes source code)
Binary tree related OJ problems
拷贝方式之DMA
随机推荐
【剑指 Offer】66. 构建乘积数组
Is it safe to open a securities account by mobile phone? Detailed steps of how to buy stocks
国内首家 EMQ 加入亚马逊云科技「初创加速-全球合作伙伴网络计划」
Global Data Center released DC brain system, enabling intelligent operation and management through science and technology
數據訪問 - EntityFramework集成
Keras crash Guide
【组队 PK 赛】本周任务已开启 | 答题挑战,夯实商品详情知识
Etcd build a highly available etcd cluster
深潜Kotlin协程(二十一):Flow 生命周期函数
【刷题篇】有效的数独
What is ROM
Writing method of twig array merging
采用药丸屏的iPhone14或引发中国消费者的热烈抢购
Starkware: to build ZK "universe"
Jarvis OJ Webshell分析
Benji Banas membership pass holders' second quarter reward activities update list
【729. 我的日程安排表 I】
Copy mode DMA
Scratch colorful candied haws Electronic Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
Fleet tutorial 09 basic introduction to navigationrail (tutorial includes source code)