Astro Islands & SSR (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Image Optimization with Astro's `<Image />` and `<Picture />`.
senior LevelCode ExamplePerformanceDocker & ContainersSystem Design
In Simple Words:
The astro:assets module automatically optimizes images:
- Resizes local images to required dimensions at build time.
- Converts formats to modern
.webpor.avif. - Auto-calculates
width,height, andaspect-ratioto eliminate Cumulative Layout Shift (CLS).
astro
---
import { Image } from 'astro:assets';
import heroImg from '../assets/hero.png';
---
<!-- Automatically generates srcset, webp conversion, and prevents layout shift -->
<Image src={heroImg} alt="Interview Hub Banner" width={800} quality="high" />