Skip to the page

Loading fast: critical path, hints, images, fonts, caching · core

Critical rendering path and render-blocking resources

The browser must build the DOM and CSSOM, combine them into a render tree, then lay out and paint; CSS in the head blocks rendering, classic scripts block parsing, and you shorten the path by sending fewer, smaller critical resources early.

The notes

What you must know

  • Steps: HTML -> DOM (incremental); CSS -> CSSOM (not incremental); DOM + CSSOM -> render tree (only visible nodes); layout (sizes and positions); paint (pixels); composite (layers to the screen).
  • CSS is render-blocking: the browser will not paint until it has the CSS in the head, because later rules can override earlier ones. A stylesheet with a non-matching media attribute (for example print) does not block.
  • A classic <script> without async/defer is parser-blocking: parsing stops while it downloads and runs. It also waits for earlier CSS, because the script might read styles.
  • defer: download in parallel, run in order after parsing. async: download in parallel, run as soon as ready, in any order. type=module scripts are deferred by default.
  • The preload scanner reads ahead in the HTML while the parser is blocked and starts fetching images, CSS and scripts early. Resources only found by JS or CSS (background images, @import, fonts) miss this.
  • Shorten the path: inline small critical CSS, split CSS per route, defer non-critical JS, avoid @import chains, put the LCP image in the HTML, and reduce round trips (preconnect, HTTP/2+, CDN).

The red pen

Common traps: mistake → fix

  • Mistake: "Images block the first render"

    Fix: images do not block rendering; CSS and sync scripts do.

  • Mistake: "async and defer are the same"

    Fix: defer keeps order and waits for parsing; async runs as soon as it arrives, in any order.

  • Mistake: "Putting scripts at the end of body is the modern best practice"

    Fix: defer in the head is better: the download starts earlier and order is kept.

  • Mistake: "HTTP/2 server push is the way to send critical CSS early"

    Fix: push was removed from Chrome; use preload or 103 Early Hints.

Easy to hard

Questions interviewers ask, easy to hard

  1. Walk me through the critical rendering path.
  2. Why is CSS render-blocking and JavaScript parser-blocking?
  3. Explain async vs defer vs type=module. Which would you use for analytics?
  4. What is the preload scanner and how can your code defeat it?
  5. How would you cut 1 second of render delay on a page that loads 300 KB of CSS?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview