关键英文词: layout paint compositecss
管道,恩, 跟linux上的概念很像,上一个处理完了交给下一个linux
JS/CSS -> layout -> paint -> compositeweb
改变元素宽高布局属性的,都会引发layout,从而有后面的管道性能优化
JS/css -> paint -> composite布局
只改变元素的颜色、阴影什么的性能
JS/css -> composite优化
目前只引发合成层渲染的CSS属性: transform
& opacity
动画
特殊使用,提高到其本身的层,建合成器层:google
will-change: transform;
transform: translateZ(0);
复制代码
合成器线程能够单独处理用户的交互并使内容更变,不需求主线程去执行,主线程执行js、布局、样式、绘制。spa
ele.getBoundingClientRect()
确保回调在下一帧开始时运行,确保当前样式已渲染OK
requestAnimationFrame(function () {
el.classList.add('animate-to-transform')
el.style.transform = ''
})
复制代码
developers.google.com/web/fundame… developers.google.com/web/fundame… developers.google.com/web/fundame…