Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Frontend System Design Roadmap
  1. 1.HTTP/1.1 vs HTTP/2 vs HTTP/3 (QUIC)
  2. 2.TCP and TLS Handshakes: Connection Setup Costs
  3. 3.Browser Network Stack and Connection Pooling
  4. 4.GET vs POST and Idempotency in HTTP
  5. 5.The Critical Rendering Path (CRP)
  6. 6.DOM, CSSOM and the Render Tree
  7. 7.Layout, Paint and Compositing
  8. 8.Reflows and Repaints Explained
  9. 9.Event Loop: Call Stack, Task and Microtask Queues
  10. 10.Async JavaScript: Promises and async/await
  11. 11.Web Workers: Multi-threading in the Browser
  12. 12.Browser Storage: Cookies, Web Storage, IndexedDB
  13. 13.Client-Side Storage: Limits and Security Risks
  14. 14.Choosing the Right Client-Side Storage
  15. 15.HTTP Caching: Cache-Control, ETag, Last-Modified
  16. 16.Browser-Level Caching Mechanisms
  17. 17.Cache Invalidation for Frontend Apps
  18. 18.Structuring a Large Single-Page App
  19. 19.Component-Based Architecture Principles
  20. 20.Props, State and Component Lifecycle
  21. 21.Module Bundling Basics
  22. 22.Core Web Vitals: LCP, INP and CLS
  23. 23.FCP and Time to Interactive (TTI) Explained
  24. 24.Measuring Performance: Lighthouse and WebPageTest
  25. 25.Asset Compression and Minification Basics
  26. 26.What Is a CDN and How Does It Work?
  27. 27.CDN Benefits: Latency, Availability, Offload
  28. 28.CDN Cache Behavior and Invalidation
  29. 29.Global State vs Local Component State
  30. 30.State Patterns: Redux, Zustand and Context
  31. 31.Data Fetching: React Query and SWR
  32. 32.Immutable Data in Frontend State
  33. 33.SSR vs CSR: Rendering Trade-offs
  34. 34.Hydration and Time to First Byte (TTFB)
  35. 35.Static Site Generation (SSG) for Speed and SEO
  36. 36.Incremental Static Regeneration (ISR)
  37. 37.Micro-Frontends: Core Principles
  38. 38.Micro-Frontend Integration Strategies
  39. 39.Communication Between Micro-Frontends
  40. 40.Micro-Frontends: Pros and Cons for Large Teams
  41. 41.Real-Time: Polling, SSE and WebSockets
  42. 42.Real-Time Use Cases: Chat, Alerts, Live Data
  43. 43.Designing a Real-Time Data Flow
  44. 44.Scaling WebSocket Connections
  45. 45.Responsive Images: srcset, sizes and picture
  46. 46.Modern Image Formats: WebP, AVIF, JPEG XL
  47. 47.Lazy Loading Images and Videos
  48. 48.Video Streaming: HLS, DASH, Adaptive Bitrate
  49. 49.REST and GraphQL for Frontend Engineers
  50. 50.Batching, Throttling and Debouncing API Calls
  51. 51.Handling API Errors in the Frontend
  52. 52.Authentication Flows: OAuth and JWT
  53. 53.Global Error Boundaries in React
  54. 54.Error Reporting: Sentry and LogRocket
  55. 55.Graceful Degradation and Fallback UIs
  56. 56.Real User Monitoring (RUM)
  57. 57.CORS: Cross-Origin Resource Sharing
  58. 58.Preventing XSS (Cross-Site Scripting)
  59. 59.CSRF Protection for Frontend Apps
  60. 60.Content Security Policy (CSP)
  61. 61.Storing Auth Tokens: Cookies vs localStorage
  62. 62.PWA Manifest and Installability
  63. 63.Service Workers: Lifecycle and Caching Strategies
  64. 64.Offline Support and Background Sync
  65. 65.Push Notifications for Web Apps
  66. 66.Webpack vs Vite vs Parcel
  67. 67.Code Splitting, Tree Shaking, Asset Optimization
  68. 68.Module Resolution and Hot Module Replacement
  69. 69.Monorepo Tooling: Nx and Lerna
  70. 70.Atomic Design for Component Libraries
  71. 71.Theming and Customization in Design Systems
  72. 72.Accessibility in Component Libraries
  73. 73.Component Library Docs, Testing and Versioning
  74. 74.Publishing and Consuming a Component Library
  75. 75.Full-Text Search: Levenshtein and Fuzzy Matching
  76. 76.Indexing Large Datasets in the Browser
  77. 77.Search Performance: Debouncing and Web Workers
  78. 78.Integrating Backend Search Services
  79. 79.Choosing a Chart Library: D3, Chart.js, Recharts
  80. 80.Rendering Large Datasets: Canvas vs SVG
  81. 81.Interactive, Responsive Data Visualizations
  82. 82.Data Fetching and Aggregation for Dashboards
  83. 83.A/B Test Design and Rollout Strategies
  84. 84.Client-Side vs Server-Side A/B Testing
  85. 85.Feature Flags and Remote Configuration
  86. 86.Experiment Data Collection and Analytics
Frontend System Design Roadmap
06

Frontend System Design · Lesson 6 of 86 · 4 min

DOM, CSSOM and the Render Tree

This is how you explain what happens before the first pixel is drawn, and why display: none is not the same as visibility: hidden.

After this lesson, you'll be able to walk an interviewer through the browser's first steps in turning code into a visual representation. You'll know the data structures involved, how they're built, and what that means for performance. This isn't just theory; it's the foundation for diagnosing rendering bottlenecks.

How the browser builds its blueprint

The browser receives bytes of HTML and CSS, but it can't render from that directly. It needs structured, in-memory representations. It builds two of these in parallel: the DOM and the CSSOM.

The Document Object Model (DOM) is the browser's object representation of your HTML document. The parser goes through the HTML, token by token, and builds a tree of nodes. <html> is the root, <body> is a child, a <div> inside that is a grandchild, and so on. This tree represents the document's structure and content.

Simultaneously, the browser parses your CSS from <link> tags, <style> blocks, and inline styles. It builds the CSS Object Model (CSSOM), another tree structure. This tree represents the styles, their specificity, and how they cascade. A rule for div p will be a child of a rule for div.

The trap: Thinking that CSS parsing waits for the DOM. It doesn't. They happen in parallel. However, the browser cannot proceed to the next stage—building the Render Tree—until it has both the complete DOM and the complete CSSOM. This is why both HTML and CSS are considered render-blocking resources.

Combining DOM and CSSOM into the Render Tree

The Render Tree is the browser's internal model of what will actually be rendered on the page. It's the synthesis of structure (DOM) and style (CSSOM).

The browser walks the DOM tree, starting from the root. For each node, it looks for matching rules in the CSSOM and calculates the computed styles for that node. It then creates a "render object" that contains both the content and the final styles.

This process creates a new tree, the Render Tree, which maps closely to the DOM but isn't a 1:1 copy.

What the Render Tree leaves out

The key is that the Render Tree only includes what is visible. This is a critical distinction.

Nodes that are not in the Render Tree:

  • Non-visual elements like <head>, <script>, <meta>, and <link>. They provide information but don't have a visual output.
  • Elements explicitly hidden with display: none. The browser knows these elements (and their children) take up no space, so it omits them entirely from the blueprint for the screen.

"What's the difference between display: none and visibility: hidden?" This is a classic question. Your answer must center on the Render Tree.

An element with display: none is not included in the Render Tree. It occupies no space and is not rendered.

An element with visibility: hidden is included in the Render Tree. It still occupies its space in the layout, creating an empty box. It just isn't painted.

Understanding this distinction shows you're thinking about layout and rendering, not just whether something is visible.

How JavaScript changes trigger updates

JavaScript interacts with the page by modifying the DOM. When you change an element's content, add a class, or alter an inline style, you are changing the DOM or, by extension, the CSSOM. The browser must then react to this change.

Consider this simple page and some JavaScript modifications.

<!DOCTYPE html>
<html>
<head>
    <title>Render Tree Example</title>
    <style>
        body { font-family: sans-serif; }
        .app { padding: 20px; background-color: #f0f0f0; }
        h1 { color: #333; }
        .hidden { display: none; }
    </style>
</head>
<body>
    <div class="app">
        <h1>Welcome!</h1>
        <p class="hidden">I am hidden.</p>
    </div>
</body>
</html>
// Get a reference to the main container
const appDiv = document.querySelector('.app');

// 1. Change content: Modifies a DOM text node
const heading = document.querySelector('h1');
heading.textContent = 'Hello, Engineer!';

// 2. Change style: Triggers CSSOM/style recalculation for one element
appDiv.style.backgroundColor = '#e0e0ff';

// 3. Unhide an element: Major change.
// This adds the element back into the Render Tree.
const hiddenP = document.querySelector('.hidden');
hiddenP.classList.remove('hidden');
hiddenP.textContent = 'I am now visible!';

Each of these changes invalidates some part of the rendering data.

  • Changing textContent or backgroundColor might only require a repaint of that element.
  • Removing the .hidden class is a bigger deal. The browser must add the element and its children back into the Render Tree, then recalculate the layout of the page to make space for it. This is a "reflow" or "layout" operation, and it's expensive.

The trap: Saying "DOM manipulation is slow" is too generic. A senior engineer explains why. It's slow because a seemingly small DOM change can force the browser to invalidate the Render Tree, recalculate the layout of many elements, and repaint the screen. The cost is in the rendering work that follows the DOM update.

Try it

Open DevTools on any site. In the Elements panel, find a visible element. Right-click and select "Hide element" (which applies display: none !important). Watch it disappear and the layout shift. Now, uncheck that style in the Styles pane, and add visibility: hidden;. See how the space is preserved. This is the Render Tree in action.

Next: We'll break down what happens after the Render Tree is built in Layout, Paint and Compositing.

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

The Critical Rendering Path (CRP)

Next

Layout, Paint and Compositing