[Performance] Optimize Paint and Composite for the website
"Paint" is one of the most preference killer, it can easily cost more than 60fps, and once you trigger "Paint" it always trigger "Composite" as well.
First of all, let's see how to use Chrome devtools to help us identifiy the Paint problem.
a. turn on rendering:
Then check the "Paint flasing" option.
Then use this demo site, keep "Paint flashing" open, and you should see when you scrolling the page, the whole page is repainting (mark in green overlay).
Of course the whole page is re-painting is not good sign for the performance.
Record the timeline for the demo page and scroll a bit, then check the Paint Profilter:
From here you can pretty much see all the commands it runs and each step what is painted to the page.
Composite:
To avoid too much painting, we can put different compoment in different layouts.
For example the side-nav compoment, to prevent the whole page re-paint again and again, we can put side nav in a different layout, so that the main page won't re-paint.
Prompt element into a layout:
Code that works:
will-change: transform;
transform: translateZ(0); // hack for some browser not support will-change
DEMO site, you can see it move really slow, but if you add the css to .box, the performance improve a lot.
Notice that, only using layer promption when you are changing the position, opacity stuff, if you want to change text in the element, layer promption doesn't make any sence
Now let's say how to figure out how many layers we have in the site.
We need again our chrome devtools to help.
Select "Layout", and nav to the demo site.
Zoom in the page, until you are able to scroll the page.
Then see the dev tool:
In the layers section, you able to see how many layers you have in the page. And it tell you the reason why it is a composition layer, in the image, it says that "Composition due to association with an element with a css 3D transform".
If you check the css code for "#color-block":
#color-block {
width: 300px;
height: 300px;
background: red;
transform: translateZ(0); // this is the key
position: relative;
z-index:;
}
And if we select "totes-promoted" block, we can see that "Composition due to association with an element overlapping other composited elements".
So be careful that when you prompt one element into a layer, the overlapping elements will be also prompted as well.
This may cause memory problem.
[Performance] Optimize Paint and Composite for the website的更多相关文章
- C++ Low level performance optimize 2
C++ Low level performance optimize 2 上一篇 文章讨论了一些底层代码的优化技巧,本文继续讨论一些相关的内容. 首先,上一篇文章讨论cache missing的重要性 ...
- C++ Low level performance optimize
C++ Low level performance optimize 1. May I have 1 bit ? 下面两段代码,哪一个占用空间更少,那个速度更快?思考10秒再继续往下看:) //v1 ...
- .net performance optimize your C# app 读书笔记
目录 序 作者简介 推荐人简介 感谢 本书简介 第一章 性能指标 第二章 性能测量 第三章 内部类型 第四章 垃圾回收机制 第五章 集合和泛型 第六章 并发和并行性 第七章 网络.I / ...
- 浏览器渲染详细过程:重绘、重排和 composite 只是冰山一角
https://juejin.im/entry/590801780ce46300617c89b8 渲染 这张很经典的图许多人都看过,其中的概念大家应该都很熟悉,也就是这么几个步骤:js修改dom结构或 ...
- Optimize Managed Code For Multi-Core Machines
Parallel Performance Optimize Managed Code For Multi-Core Machines Daan Leijen and Judd Hall This ar ...
- (转) [it-ebooks]电子书列表
[it-ebooks]电子书列表 [2014]: Learning Objective-C by Developing iPhone Games || Leverage Xcode and Obj ...
- Java性能提示(全)
http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...
- 基于Webkit的浏览器关键渲染路径介绍
关键渲染路径概念 浏览器是如何将HTML.JS.CSS.image等资源渲染成可视化的页面的呢?本文简单介绍一下渲染过程中涉及到的关键步骤. 该过程分为四步:模型对象的构建.渲染树构建.布局.绘制. ...
- IntersectionObserver API
温馨提示:本文目前仅适用于在 Chrome 51 及以上中浏览. 2016.11.1 追加,Firefox 52 也已经实现. 2016.11.29 追加,Firefox 的人担心目前规范不够稳定,未 ...
随机推荐
- SQL SERVER读书笔记:TempDB
每次SQL SERVER启动的时候,会重新创建. 用于 0.临时表 1.排序 2.连接(merge join,hash join) 3.行版本控制 临时表与表变量的区别: 1)表变量是存储在内存中的, ...
- 转四种常见的post请求
HTTP/1.1 协议规定的 HTTP 请求方法有 OPTIONS.GET.HEAD.POST.PUT.DELETE.TRACE.CONNECT 这几种.其中 POST 一般用来向服务端提交数据,本文 ...
- JavaScript:目录
ylbtech-JavaScript:目录 1. https://www.javascript.com/ 2. 1.返回顶部 1. http://www.runoob.com/js/js-functi ...
- 【NOIP2011 Day 1】选择客栈
[问题描述] 丽江河边有n家客栈,客栈按照其位置顺序从1到n编号.每家客栈都按照某一种色调进行装饰(总共k种,用整数0 ~ k-1表示),且每家客栈都设有一家咖啡店,每家咖啡店均有各自的最低消费.两位 ...
- docker(部署常见应用):docker部署mysql
上节回顾:docker(部署常见应用):docker部署nginx docker部署mysql:5.7.26 # 下载镜像 docker pull mysql: # 查看镜像 docker image ...
- C - Young Physicist
Problem description A guy named Vasya attends the final grade of a high school. One day Vasya decide ...
- web前端处理订单待支付倒计时计算显示问题
在商城类项目的时候,有很多待支付的订单,有时候在订单列表页面会分别显示倒计时,就是页面会有很多倒计时的订单. 处理方法: 1.调用后端接口拿到所有的订单,获取所有的倒计时订单,获取到期时间(尽量时间戳 ...
- JavaScript DOM 总结
一.DOM基础1.节点(node)层次Document--最顶层的节点,所有的其他节点都是附属于它的.DocumentType--DTD引用(使用<!DOCTYPE>语法)的对象表现形式, ...
- let,const,var三者之间的区别
在ES6中新增了两种定义变量的命令let和const,在这之前相信大家都对var定义变量很熟悉,那么在了解ES6方法前, 1.我们先来回顾一下var定义变量的方法. 下面来看这段代码: for (va ...
- Oracle数据库安装与连接与简介
Oracle数据库的安装 1.登录Oracle官网——试用和下载 2.同意协议--->file1 3.完成配置 4.测试连接:打开Oracle developer--->新建连接,注意用户 ...