Skip to content

Instantly share code, notes, and snippets.

@lsirivong
Created July 7, 2015 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsirivong/04bb7f43e64b72075938 to your computer and use it in GitHub Desktop.
Save lsirivong/04bb7f43e64b72075938 to your computer and use it in GitHub Desktop.
IWP - Performance Debugging in Chrome

Chrome Performance Debugging

Lenny Sirivong @lsirivong

rendering pipeline

Parse HTML > Recalculate Styles > Layout > Paint > Composite Layers

4 points in app lifescycle RAIL (or LIAR)

  • load - 1s
    • prioritize first load content
  • idol - 100ms
    • pause after load, before user starts interacting with the site
    • perfect for preloading lower priority content
  • animate - 16ms / frame
    • animations should be 60fps, especially scroll & touch/drag
  • response - 100ms
    • responding to user input

3 ways JS / CSS can trigger style changes:

  1. visual change
  • layout property (width, height, position in relation to another - causes layout)
  • most expensive
  1. paint only property
  • paint property (color, shadow, background etc.)
    • skips layout
  1. composite property
  • skips layout & paint
  • browser puts individual layers together. involves layer management
  • most performant

csstriggers.com

javascript

~/src/iwp/web-workers-demo

http://output.jsbin.com/aqavin/2/quiet

forced syncronous layout

http://udacity.github.io/60fps/lesson5/stopFSL/index.html

causing layout, and requesting style, causes the browser to recalc before being able to send result.

Styles

  1. ~/src/recalc

Paint & Composite

Chrome Rendering Tab

  • show paint rectangles

http://www.html5rocks.com/static/demos/parallax/demo-1a/demo.html

Paint Profiler

layers help with paint costs

paint steps:

  1. update layer tree
  2. composite layers

generally browser will manage layers but you can promote elements to its own layer

// hint to the browser we intend to change this property at some point, browser can decide what to do
will-change: transform

// older browsers (safari)
// null transform hack
transform: translateZ(0);

http://udacity.github.io/60fps/lesson6/willChange/index.html

This isn't a silver bullet

Further Reading

Paul Lewis (@aerotwist) live debugging
https://www.youtube.com/watch?v=QU1JAW5LRKU

Udacity course on Browser Rendering Optimization
https://www.udacity.com/course/browser-rendering-optimization--ud860

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment