Browser performance

5 concepts · 10 practice questions

The critical rendering path

To show a page the browser parses HTML into the DOM and CSS into the CSSOM, combines them, lays out the boxes, paints and composites. CSS in the head is render-blocking: nothing paints until it is loaded, to avoid a flash of unstyled content. A plain script tag blocks the HTML parser while it downloads and runs. defer downloads in parallel and runs after parsing, in order; async runs as soon as it arrives, in any order. Preload resources the parser would find late, such as fonts and the hero image.

<head>
  <link rel="stylesheet" href="/app.css" />
  <link rel="preload" href="/fonts/inter.woff2" as="font" type="font/woff2" crossorigin />
  <script src="/vendor.js" defer></script>
  <script src="/app.js" defer></script>  <!-- runs after vendor.js -->
  <script src="/analytics.js" async></script> <!-- independent -->
</head>

Also covered

Layout, paint and compositing
Core Web Vitals
Code splitting and lazy loading
HTTP caching and service workers

Sign in to read the rest and take the 10-question test.

Sign in to continue