Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What's render blocking? - React London Meetup

Avatar for Csaba Palfi Csaba Palfi
November 06, 2017

What's render blocking? - React London Meetup

What is render-blocking and how to avoid it? - how we optimised our critical rendering path and some gotchas along the way.

Avatar for Csaba Palfi

Csaba Palfi

November 06, 2017

More Decks by Csaba Palfi

Other Decks in Technology

Transcript

  1. browsers: browsers: 1. 1. get HTML get HTML → DOM

    → DOM 2. link to CSS → 2. link to CSS → get CSS get CSS → CSSOM → CSSOM 3. DOM + CSSOM → render tree 3. DOM + CSSOM → render tree 4. render tree → layout/reflow 4. render tree → layout/reflow 5. layout/reflow → paint 5. layout/reflow → paint
  2. ⚠ critical path ⚠ critical path resources → pixels on

    the screen resources → pixels on the screen goal: getting to paint ASAP goal: getting to paint ASAP
  3. render-blocking render-blocking CSS CSS <link> <link> to CSS → to

    CSS → get CSS get CSS → CSSOM → CSSOM
  4. is it happening? is it happening? first-paint first-paint ( (

    ) ) - ( - ( ) ) Paint Timing API Paint Timing API Start Render Start Render webpagetest.org webpagetest.org
  5. let's find a page let's find a page that has

    the problem that has the problem
  6. ✅ Inline critical CSS ✅ Inline critical CSS embed styles

    for rendering above-the fold content <style> /* yes, here */ </style>
  7. ⬇ Async loading CSS ⬇ Async loading CSS for below

    the fold <link rel="preload" href="..." as="style" onload="this.rel='stylesheet'" >
  8. baseline vs fixed baseline vs fixed first-paint first-paint <0.5s →

    <0.5s <0.5s → <0.5s ~3s → ~1s ~3s → ~1s ~10s -> ~2s ~10s -> ~2s
  9. are we done? are we done? is this even your

    bottleneck? is this even your bottleneck? how many slow 3G users? - tricky how many slow 3G users? - tricky it's sooo not just about first-paint it's sooo not just about first-paint #LNM 14/11 #LNM 14/11
  10. below the fold below the fold where is the fold?

    where is the fold? what if the user scrolls early? what if the user scrolls early?
  11. ⚒ critical CSS ⚒ critical CSS how to extract (but

    e.g. styletron) how to extract (but e.g. styletron) keeping it small keeping it small testing with critical CSS only testing with critical CSS only @import @import, relative , relative url(...) url(...)s s
  12. Should've been a Should've been a blog post? blog post?

    - bit out of date - bit out of date also also by Google by Google I have a blog post, too! I have a blog post, too! Critical Rendering Path Critical Rendering Path