Course contentsShow
← Web Development
Lesson 1749 of 2,98232. Server-Side Rendering ConceptsFree lesson

Performance Cost of Hydration

Understanding the JavaScript execution overhead and how hydration impacts Time to Interactive.

Performance Cost of Hydration

You'll learn: How hydration's JavaScript execution overhead delays Time to Interactive and impacts user experience.

The Hidden Tax

When your server sends fully-rendered HTML, users see content immediately—but they can't interact with it yet. Hydration is the process where JavaScript "wakes up" the static HTML, attaching event listeners and making components interactive. This process comes with a performance cost: the browser must download, parse, and execute all the JavaScript needed to reconstruct the component tree and wire up interactivity.

Why Hydration Delays Time to Interactive

Time to Interactive (TTI) measures when a page becomes fully responsive to user input. Hydration directly extends TTI because:

  1. JavaScript bundle size: The framework code plus your application code must download completely
  2. Parsing overhead: The browser must parse all that JavaScript
  3. Execution time: React/Vue/etc. must traverse the server-rendered DOM, build the virtual component tree, and attach event handlers
  4. Main thread blocking: During hydration, the main thread is busy—user clicks may be ignored or delayed

Think of it like a puppet show: the audience sees beautiful puppets (server-rendered HTML), but those puppets can't move until the puppeteer arrives, sets up the strings, and starts controlling them (hydration completes). The bigger and more complex the puppet show, the longer the setup takes.

The Trade-off

Server-side rendering gives you a fast First Contentful Paint (users see content quickly), but hydration can give you a slow Time to Interactive (users wait to click buttons). Large JavaScript bundles make this worse—a 500KB framework bundle might take several seconds to hydrate on mobile devices.

Key Takeaway: Hydration improves perceived performance but delays actual interactivity—minimizing JavaScript bundle size and optimizing hydration strategies are critical for maintaining a good Time to Interactive.