#How to fix header logo loading
3 messages · Page 1 of 1 (latest)
Hi @solar shore. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
For above-the-fold images like a header logo, you should use the priority prop on Astro's <Image /> component. This automatically sets the optimal loading attributes for images that are immediately visible when the page loads. [priority prop]
---
import { Image } from 'astro:assets';
import logo from '../assets/logo.png';
---
<Image src={logo} alt="My site logo" priority />
When priority is set, Astro will automatically apply these attributes:
loading="eager"
decoding="sync"
fetchpriority="high"
This tells the browser to load the image immediately, which is exactly what you want for an above-the-fold element like a header logo. [priority prop]
Note: The
priorityprop was added in[email protected]. Make sure you're on a compatible version.