Eager vs Lazy vs Auto Loading
What you'll learn: The three values for the loading attribute and when each one helps your page perform better.
Now that you know native lazy loading exists, let's understand all three options you can use for the loading attribute on images and iframes.
The Three Loading Strategies
loading="lazy" tells the browser to wait before downloading the image until it's needed (typically when it's about to enter the viewport). Perfect for images below the fold—why download something users might never scroll to?
loading="eager" explicitly tells the browser to download the image immediately, regardless of where it appears on the page. This ensures critical images load as fast as possible without any delay.
loading="auto" (or omitting the attribute entirely) leaves the decision to the browser. The browser uses its own heuristics to decide what's best, which is usually smart but less predictable.
When to Use Each
Use eager for:
- Hero images above the fold
- Logos and brand elements
- Any image users see immediately on page load
- The first image in an article or gallery
Use lazy for:
- Images far down the page
- Gallery thumbnails below the fold
- Footer images
- Comments or user-generated content
Use auto when:
- You're unsure and want the browser to decide
- Testing to see default behavior
The Performance Trade-off
Think of it like restaurant service: eager is ordering everything at once (fast but wasteful if you don't finish), lazy is ordering courses as you're ready (efficient but slight delay), and auto is letting the waiter suggest the timing.
Key Takeaway: Use loading="eager" for critical above-the-fold images to ensure instant visibility, loading="lazy" for below-the-fold content to save bandwidth and speed up initial page load, and let loading="auto" be the default when you're uncertain—most modern browsers will make reasonable choices.