Step 19: Partial Hydration

The Solution: Partial Hydration

Instead of hydrating all components at once, we can use partial hydration to hydrate components only when they're needed.

Notice how each card gets hydrated individually when hovered over.

Don't forget to enable provideClientHydration(withIncrementalHydration()) in app.config.ts!

Benefits:

  • Reduced initial JavaScript bundle
  • Faster Time to Interactive (TTI)
  • Better memory usage
  • Improved performance on mobile devices

Implementation:


Edefer (on hover) {
  <div class="card interactive">
    <!-- Interactive content -->
  </div>
} Eplaceholder {
  <div class="card non-interactive">
    <!-- Static content -->
  </div>
}
          

Hover over any card to hydrate it. Notice how each card becomes interactive individually, rather than all at once.

Check the console to see when each card gets hydrated!

Card 1

✨ On hover to hydrate!

Card 2

✨ On hover to hydrate!

Card 3

✨ On hover to hydrate!

Card 4

✨ On hover to hydrate!

Card 5

✨ On hover to hydrate!

Card 6

✨ On hover to hydrate!

Card 7

✨ On hover to hydrate!

Card 8

✨ On hover to hydrate!

Card 9

✨ On hover to hydrate!

Card 10

✨ On hover to hydrate!

Card 11

✨ On hover to hydrate!

Card 12

✨ On hover to hydrate!

Card 13

✨ On hover to hydrate!

Card 14

✨ On hover to hydrate!

Card 15

✨ On hover to hydrate!

Card 16

✨ On hover to hydrate!

Card 17

✨ On hover to hydrate!

Card 18

✨ On hover to hydrate!

Card 19

✨ On hover to hydrate!

Card 20

✨ On hover to hydrate!

Card 21

✨ On hover to hydrate!

Card 22

✨ On hover to hydrate!

Card 23

✨ On hover to hydrate!

Card 24

✨ On hover to hydrate!

Card 25

✨ On hover to hydrate!

Card 26

✨ On hover to hydrate!

Card 27

✨ On hover to hydrate!

Card 28

✨ On hover to hydrate!

Card 29

✨ On hover to hydrate!

Card 30

✨ On hover to hydrate!