Lessons in this course (12)

7. How the browser renders a page

Intermediate★ Must knowLesson 7 of 12
  1. Receive HTML bytes → decode → tokenize → build the DOM.
  2. Find <link rel=stylesheet> → download → build the CSSOM (CSS blocks rendering).
  3. Find <script> → download and execute (blocks parsing unless defer/async/type=module).
  4. DOM + CSSOM → render tree → layout (positions/sizes) → paint → composite layers on the GPU.
  5. Images, fonts, more scripts are requested in parallel; the page becomes interactive when JavaScript has run.
  6. JavaScript changes (DOM updates) may trigger re-layout and re-paint.

Speed-ups: fewer/smaller requests, compression (Brotli/gzip), HTTP/2/3, CDN, caching headers, lazy-loading images, defer scripts, critical CSS, preconnect/preload hints. Measure with Lighthouse and Core Web Vitals (LCP, INP, CLS).