"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的更多相关文章

  1. C++ Low level performance optimize 2

    C++ Low level performance optimize 2 上一篇 文章讨论了一些底层代码的优化技巧,本文继续讨论一些相关的内容. 首先,上一篇文章讨论cache missing的重要性 ...

  2. C++ Low level performance optimize

    C++ Low level performance optimize 1.  May I have 1 bit ? 下面两段代码,哪一个占用空间更少,那个速度更快?思考10秒再继续往下看:) //v1 ...

  3. .net performance optimize your C# app 读书笔记

    目录 序 作者简介 推荐人简介 感谢 本书简介 第一章  性能指标 第二章  性能测量 第三章  内部类型 第四章  垃圾回收机制 第五章  集合和泛型 第六章  并发和并行性 第七章  网络.I / ...

  4. 浏览器渲染详细过程:重绘、重排和 composite 只是冰山一角

    https://juejin.im/entry/590801780ce46300617c89b8 渲染 这张很经典的图许多人都看过,其中的概念大家应该都很熟悉,也就是这么几个步骤:js修改dom结构或 ...

  5. Optimize Managed Code For Multi-Core Machines

    Parallel Performance Optimize Managed Code For Multi-Core Machines Daan Leijen and Judd Hall This ar ...

  6. (转) [it-ebooks]电子书列表

    [it-ebooks]电子书列表   [2014]: Learning Objective-C by Developing iPhone Games || Leverage Xcode and Obj ...

  7. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

  8. 基于Webkit的浏览器关键渲染路径介绍

    关键渲染路径概念 浏览器是如何将HTML.JS.CSS.image等资源渲染成可视化的页面的呢?本文简单介绍一下渲染过程中涉及到的关键步骤. 该过程分为四步:模型对象的构建.渲染树构建.布局.绘制. ...

  9. IntersectionObserver API

    温馨提示:本文目前仅适用于在 Chrome 51 及以上中浏览. 2016.11.1 追加,Firefox 52 也已经实现. 2016.11.29 追加,Firefox 的人担心目前规范不够稳定,未 ...

随机推荐

  1. Linux下用ImageMagick玩图像魔术【转】

    本文转载自:http://www.linuxdiyf.com/linux/11680.html 不管你知不知道,现在是一个用ImageMagick的好机会,至少,如果你是一个Linux用户的话.这是一 ...

  2. AUTOCAD2013 以上利用ACCORECONSOLE+ SCR后台批量清理图纸

    无意中浏览到南胜大神的博客,https://www.cnblogs.com/NanShengBlogs/p/10957489.html 受此启发,特意改装此方法用于批量清理图纸,效果极佳. 详细介绍详 ...

  3. POJ 1654 乱搞题?

    题意: 从一个点出发,8个方向,给出每一步的方向,求出走过的路径形成的多边形的面积. 思路: 先普及一下向量叉乘.. (摘自度娘) 也就是x1y2-x2y1. 那这不就好说了嘛. 一个经过原点的闭合多 ...

  4. HBase编程 API入门系列之HTable pool(6)

    HTable是一个比较重的对此,比如加载配置文件,连接ZK,查询meta表等等,高并发的时候影响系统的性能,因此引入了“池”的概念. 引入“HBase里的连接池”的目的是: 为了更高的,提高程序的并发 ...

  5. 如何在Hexo中实现自适应响应式相册功能

    用最清晰简洁的方法整合一个响应式相册 效果 技术选型 由于我选用的主题使用了fancyBox作为图片弹出展示的框架,查看后表示很不错,能满足需要 http://fancyapps.com/fancyb ...

  6. 杭电2602 Bone Collector 【01背包】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 解题思路:给出一个容量为V的包,以及n个物品,每一个物品的耗费的费用记作c[i](即该物品的体积 ...

  7. 00-- 关于C++ const 的全面总结

    转:关于C++ const 的全面总结 C++中的const关键字的用法非常灵活,而使用const将大大改善程序的健壮性,本人根据各方面查到的资料进行总结如下,期望对朋友们有所帮助. Const 是C ...

  8. Robot Framework(二)测试数据语法

    2.1.1文件和目录 测试数据的层次结构安排如下: 测试数据在测试数据文件中创建. 测试数据文件会自动创建一个包含该文件中的测试数据的测试套件. 包含测试数据文件的目录构成了更高级别的测试套件.这样的 ...

  9. Laravel5.6安裝:Warning: require(../vendor/autoload.php): failed to open stream: No such file or directory

    在phpstudy下使用composer+laravel安装器的方式安装了Laravel,但是访问的时候报错: Warning: require(D:\phpstudy\WWW\public\mybl ...

  10. javaee 文件的复制

    package Shurushucu; import java.io.FileInputStream; import java.io.FileNotFoundException; import jav ...