Skip to main content
InterviewHubPRO
Section Overview
Q41

Question 41 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

82%
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:

  1. Resizes local images to required dimensions at build time.
  2. Converts formats to modern .webp or .avif.
  3. Auto-calculates width, height, and aspect-ratio to 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" />