HTML Lazy Loading and Fetch Priority
Keep important images eager
loading="lazy" can defer fetching eligible offscreen images or frames. Do not lazy-load the main above-the-fold image when it is needed immediately. Explicit width and height reserve an aspect ratio before decoding; keep alternative text meaningful. These local data images illustrate attributes, not network scheduling.
<img src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22160%22%20height%3D%2290%22%3E%3Crect%20width%3D%22160%22%20height%3D%2290%22%20fill%3D%22teal%22%2F%3E%3C%2Fsvg%3E" alt="Teal illustration" width="160" height="90" loading="eager">The image has eager loading and explicit dimensions.
Defer below-the-fold resources
Lazy loading is a browser scheduling heuristic rather than an exact visibility trigger. A browser may start a request before the resource is visible. This example places a labeled secondary image after a tall spacer. The data URL requires no remote fetch, so use it to study markup only.
<p style="min-height: 900px">Article introduction</p><img src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22160%22%20height%3D%2290%22%3E%3Crect%20width%3D%22160%22%20height%3D%2290%22%20fill%3D%22teal%22%2F%3E%3C%2Fsvg%3E" alt="Secondary teal illustration" width="160" height="90" loading="lazy">The secondary image declares lazy loading.
Use priority and decoding hints sparingly
fetchpriority suggests relative fetching importance (high, low, auto). decoding suggests how image decoding may be scheduled (sync, async, auto). These are not hard guarantees and do not replace measurement. Excessive high-priority requests compete with other important work.
<img src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22160%22%20height%3D%2290%22%3E%3Crect%20width%3D%22160%22%20height%3D%2290%22%20fill%3D%22teal%22%2F%3E%3C%2Fsvg%3E" alt="Main illustration" width="160" height="90" fetchpriority="high" decoding="async">The two hint values are reflected.
Common mistakes and practice
Reserve space for images and keep critical content discoverable in initial HTML. Compare cold and warm loads under representative network conditions. Never claim that a reflected property proves a specific scheduling improvement.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Lazy Loading and Fetch Priority — Knowledge Check
Apply the security, privacy and performance concepts taught in this lesson.
Which image should generally not be lazy-loaded?
What do image dimensions help reserve?
What is fetchpriority high?
What does decoding async concern?
Does lazy loading guarantee exact viewport-triggered fetching?