What's the differences between rendering and painting event in Chrome DevTool Timeline View

前端 未结 3 812
孤独总比滥情好
孤独总比滥情好 2021-02-03 19:15

I think the render and paint just both mean rendering the page, show the DOM

What\'s the differences?

相关标签:
3条回答
  • 2021-02-03 19:33
     Rendering            Painting     
    
       ______________
      / E      F /   |
     ____________    |    ____________
     |      A    |   |    |     A     |
     |           | G |    |           |
     |           |   |    |           |
     | B      D  |   |    | B      D  |
     |           |   |    |           |
     |     C     | H/     |     C     |
     |___________|_       |___________
    
    0 讨论(0)
  • 2021-02-03 19:41

    In recent versions of Chrome (v51+) there are two relevant events in the timeline: layout and paint (there is no longer a "render" event).

    • layout refers to the process of construting a render-tree and using that tree to compute the exact position and size of each object

    • painting refers to the process of taking the previously computed positions drawing the colors to the screen

    Layout has a notion of three-dimensions (z-indexes), structure (lines, boxes, flow) and parent-child relationships (trees). In painting, we flatten all of this information down to two-dimensions. The result of a paint is just a 2d-grid of pixels and their colors. It's what you see on the screen. All structure has been lost.

    More information: https://developers.google.com/web/fundamentals/performance/critical-rendering-path/render-tree-construction?hl=en

    0 讨论(0)
  • 2021-02-03 19:48

    Rendering events are about computing styles associated with each DOM node (i.e. "Style Recalculate") and elements position on the page ("Layout"). Paint category is about actually painting pixels and includes events like "Paint" itself and "Decode Image" / "Resize Image". In a nutshell, it's about inner structure vs. appearance -- if your page spends a lot of time rendering, this is because of the structure of its DOM and CSS (e.g. a large DOM tree), while significant paint times often mean the appearance of the page is affecting the performance (e.g. some styles are expensive to paint or an image is too large).

    0 讨论(0)
提交回复
热议问题