loading
Lazy loading, fetch priority, and image decoding hints. Three attributes that work as a set to control how and when the browser loads resources.
Overview
Three native attributes control when and how the browser fetches resources. Used together, they form a performance strategy:
loadingcontrols when a resource starts loadingfetchprioritycontrols how urgently a resource is fetched relative to othersdecodingcontrols whether image decoding blocks rendering
loading
Defers resource loading until the element is near the viewport. Use loading="lazy" on images and iframes below the fold.
| Value | Behavior |
|---|---|
eager | Load immediately (the default) |
lazy | Defer loading until near the viewport |
When Not to Lazy Load
- Above-the-fold images should load immediately. Lazy-loading your LCP image delays it.
- Small images (icons, avatars) have little to gain from lazy loading.
- Background images in CSS are not affected by the
loadingattribute.
fetchpriority
Tells the browser how important a resource is relative to others of the same type. The browser already assigns default priorities; this attribute lets you override them.
| Value | Behavior |
|---|---|
high | Fetch at higher priority than normal |
low | Fetch at lower priority than normal |
auto | Let the browser decide (the default) |
Applies to: <img>, <link>, <script>, <iframe>
LCP Optimization
The most common use: add fetchpriority="high" to your Largest Contentful Paint image. This tells the browser to prioritize that image over other resources discovered at the same time.
decoding
Hints whether image decoding should block rendering. Decoding converts the compressed image data into pixels. For large images, this can take noticeable time.
| Value | Behavior |
|---|---|
async | Decode off the main thread (non-blocking) |
sync | Decode synchronously (blocks rendering) |
auto | Let the browser decide (the default) |
Applies to: <img>
Putting It All Together
A typical page uses all three attributes as a system:
- Hero/LCP image:
fetchpriority="high"+decoding="async" - Below-fold images:
loading="lazy"+decoding="async" - Third-party embeds:
loading="lazy"