My Astro Blog

Optimizing Astro Performance

Published on Mar 5, 2025

While Astro is fast by default, there are several techniques you can use to optimize your site even further.

Image Optimization

Use Astro's built-in Image component for automatic optimization:

---
import { Image } from 'astro:assets';
import heroImage from '../assets/hero.jpg';
---

Hero image

Smart Component Hydration

Choose the right hydration strategy for your components:

  • client:load - Load immediately
  • client:idle - Load when browser is idle
  • client:visible - Load when scrolled into view
  • client:media - Load based on media query

Code Splitting

Astro automatically splits your code for optimal delivery. Each page is compiled independently, ensuring users only download what they need.

Select Theme