blog's People
blog's Issues
TypeScript资源集
页面渲染
像素渲染流水线
- 下载HTML文档
- 解析HTML文档,生成DOM树
- 下载文档中引用的css和js资源
- 解析CSS样式表,生成CSSOM
- 将js代码交给js引擎执行
- 合并DOM和CSSOM,生成Render Tree
- 根据Render Tree进行布局layout(为每个元素计算尺寸和位置信息)
- 绘制paint每个层中的元素
- 执行图层合并
- CSS (外链或內联)会阻塞整个DOM的渲染(Rendering),然后DOM解析(Parsing)会正常进行。
- JS(外链或內联)会阻塞后续DOM的解析(Parsing),后续DOM的渲染(Rendering)也将被阻塞。
- 动态插入的外部样式表或脚本不阻塞DOM解析或渲染。
- 动态插入的内联样式表或脚本会阻塞DOM解析和渲染。
- 未连接到DOM树的样式表或脚本(外链或內联)不会被下载、解析或执行。
- 可以通过onload和onerror监听HTML资源标签载入结果,兼容IE需要onreadystatechange
渲染流程单线程,网络部分是多线程
回流(reflow):当render tree中的一部分(�或全部)因为元素的规模尺寸、隐藏、布局等改变需要重新构建,就成为回流。
当完成回流后,浏览器会重新绘制受影响的部分到屏幕中,该过程称为重绘。
css加载不会阻塞DOM树的解析
css加载会阻塞DOM树的渲染
css加载会阻塞后面js语句的执行
优化策略
- 分割css
- 高效的css规则
- GPU加速
- 异步js,js的执行会阻塞DOM的构建过程,DOM树解析到非异步的外链js时会阻塞住,在它加载并且执行完之前不会往下解析DOM树
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.