Back
Web Fundamentals

Critical Rendering Path

Web Fundamentals
Build & Deployment: Monorepo, CI/CD, Strategies & Release SafetyState Management: Choosing the Right SolutionRedux: Predictable State Container (RTK + RTK Query)React Query (TanStack Query): Server State CachingData Fetching Patterns: REST, GraphQL, tRPC & Real-timeGraphQL Fundamentals for Frontend: Shape, Caching, and TradeoffsgRPC-Web Fundamentals: Browser Constraints and Proxy ModelCaching Strategies: Client, Server & EdgeData Normalization: Organizing State for PerformanceAPI Design Best Practices: Pagination, Errors, Versioning & Type SafetyAPI Versioning Strategies for Frontend CompatibilityPagination: Offset vs Cursor-BasedRate Limiting & API Resilience: Retries, Backoff, Jitter, IdempotencyHow Frontend Developers Can Handle Millions of API Requests Without Crashing EverythingBrowser Storage: Cookies, SessionStorage, LocalStorage, IndexedDBReal-time Communication: WebSockets, SSE & PollingWebRTC: Real-Time Communication in the BrowserCore Web Vitals: LCP, INP & CLSPerformance Optimization Trade-offsCritical Resource Prioritization: Optimize Loading OrderCode Splitting: Optimize Bundle Size with Dynamic ImportsTree Shaking: Eliminate Dead Code from Your BundleLazy Loading: Load Resources On-DemandResource Hints: Preload, Prefetch & PreconnectText Compression: Gzip and BrotliImage & Video Optimization: Modern Formats & TechniquesAdaptive Loading: Optimize for Device & NetworkList Virtualization: Render Large Lists EfficientlyWeb Workers vs Main Thread: Offloading Heavy WorkMemory Leaks in Frontend Apps: Detection & PreventionManaging Third-Party Scripts: Optimization StrategiesHow CDNs Work: Edge Delivery, Caching & PerformanceHTTP Caching Deep Dive: Cache-Control, ETag & RevalidationService Workers & Offline Strategy: Cache First, Network First & Update LifecyclePWA Fundamentals: Manifest, Installability & Offline UXCritical Rendering PathScript Loading: async vs deferEvent Loop: Understanding JavaScript Execution ModelJavaScript Module Systems: CJS vs ESM vs UMDDynamic Module Loading: import() FunctionImport on Interaction: Load When User InteractsImport on Visibility: Lazy Loading with IntersectionObserverBrowser Rendering Pipeline & Layout ThrashingRendering Strategies: CSR vs SSR vs SSG vs ISRStreaming SSR: Progressive HTML StreamingIslands Architecture: Independent Component HydrationReact Server Components: Zero-JS Server RenderingFramework Reactivity: React, Vue, Svelte & SolidHTTP/1.1 vs HTTP/2 vs HTTP/3 (QUIC) for Frontend PerformanceDNS Resolution: Path, TTL, Caching & Frontend ImpactCross-Site Scripting (XSS) AttacksCross-Site Request Forgery (CSRF) AttacksCORS Explained: Cross-Origin Resource SharingCORS Preflight in Practice: Credentials, Simple Requests & MisconfigurationsContent Security Policy (CSP)Why is HTTPS Secure? Understanding TLS/SSLAuthorization Best PracticesCookie Security & Session Hardening: SameSite, HttpOnly, Secure
mediumRendering & Browser Architecture

Critical Rendering Path

TL;DRHTML → DOM + CSSOM → Render Tree → Layout → Paint → Composite
Very High Signal
Google
Meta
Netflix
30-Second Answerstart every interview with this

The Critical Rendering Path is the sequence the browser follows to turn HTML, CSS, and JavaScript into pixels on the screen. The interview-safe version is: HTML parsing builds the DOM, CSS builds the CSSOM, both combine into the Render Tree, followed by Layout (geometry), Paint (pixels), and Composite (GPU layers).

The browser is a factory. Raw materials (HTML bytes) enter → get shaped into parts (DOM & CSSOM) → assembled into a blueprint (Render Tree) → positioned (Layout) → painted (Paint) → finally put together on the screen by the GPU (Composite).

HTML Bytes
Parser + Preload Scanner
DOM + CSSOM
Render Tree
Layout → Paint → Composite
Pixels on Screen

1Step 1 — HTML Parsing & DOM Construction

The browser starts parsing HTML incrementally as soon as bytes arrive. A preload scanner runs in parallel to discover CSS, JS, fonts, and images early.

index.htmlhtml
<script src="app.js"></script>          <!-- parser-blocking -->
<script async src="app.js"></script>       <!-- loads parallel, executes ASAP (unordered) -->
<script defer src="app.js"></script>       <!-- loads parallel, executes after parse -->

2Step 2 — CSS Parsing & CSSOM Construction

CSS is render-blocking by default. The browser needs the CSSOM before first paint.

3Step 3 — Render Tree Construction

Combines DOM + CSSOM. Excludes non-visual nodes and adds pseudo-elements (::before, ::after).

4Step 4 — Layout (Reflow)

Calculates geometry. Expensive. Avoid layout thrashing (e.g. reading offsetHeight after style changes).

5Step 5 — Paint

Fills pixels (text, backgrounds, borders, images).

6Step 6 — Composite

GPU combines layers. Cheap for transform & opacity.

Propertydisplay: nonevisibility: hidden
BehaviorRemoves element from Render Tree entirelyKeeps element in Render Tree but invisible
Use CaseHiding elements that should not occupy spaceHiding while preserving layout
Impact On LayoutNo space reserved, flow is brokenFull layout space is reserved

display: none

Behavior

Removes element from Render Tree entirely

Use Case

Hiding elements that should not occupy space

Impact On Layout

No space reserved, flow is broken

visibility: hidden

Behavior

Keeps element in Render Tree but invisible

Use Case

Hiding while preserving layout

Impact On Layout

Full layout space is reserved

Common questions

  • ›“Walk me through the Critical Rendering Path.”
  • ›“What blocks First Contentful Paint and how do you optimize it?”
  • ›“Explain parser-blocking vs render-blocking.”
  • ›“How do defer and async scripts affect the CRP?”

What interviewers look for

  • Clear distinction between parser-blocking and render-blocking
  • Knowledge of preload scanner and Render Tree synchronization
  • Mapping optimizations to pipeline stages
  • Understanding async vs defer behavior

Short answer (60 sec)

HTML → DOM + CSSOM → Render Tree → Layout → Paint → Composite. CSS is render-blocking, synchronous JS is parser-blocking.

Detailed answer (senior level)

The full pipeline includes preload scanning, style recalculation, rasterization, and GPU compositing. Render Tree is the key sync point. Use defer for scripts and inline critical CSS to improve FCP.

  • Thinking CSS blocks parsing (it blocks rendering)
  • Confusing async and defer
  • Believing Layout happens before Render Tree
  • Treating Paint and Composite as identical
Key Takeaways
  • ✓Simplified CRP (interview answer): DOM + CSSOM → Render Tree → Layout → Paint → Composite
  • ✓CSS blocks rendering. Synchronous JS blocks parsing.
  • ✓async = parallel + immediate execution (unordered). defer = parallel + after parsing.
  • ✓Animate transform/opacity → stays in Composite stage.
  • ✓Batch reads/writes to avoid layout thrashing.
Previous TopicPWA Fundamentals: Manifest, Installability & Offline UXNext Topic Script Loading: async vs defer

On this page