Menu

Lazy loading a product grid: which images should never get loading="lazy"
📰

Lazy loading a product grid: which images should never get loading="lazy"

DEV Community: html·RAMO·1 day ago
#Fi0U3swi
#devto2#devto#dev#lazy#first
Reading 0:00
15s threshold

Adding loading="lazy" to every <img> on a category page feels like free performance. It mostly is. The catch is the handful of images where it does the opposite of what you want, and on a store those are usually the most important ones.

Here's the short version of how I decide, image by image.

The rule of thumb

Lazy loading tells the browser: "don't fetch this until it's about to scroll into view." That's great for row 6 of a product grid. It's bad for anything the visitor sees the moment the page opens, because the browser now waits until layout is done to decide the image is "near the viewport" before it even starts the request.

So the question for each image is simply: is it visible without scrolling on a typical screen?

Yes: load it normally. If it's the largest thing on screen, give it a priority hint too.

No: lazy load it.

Not sure: lean towards eager for the first few items, lazy for the rest.

The images people lazy load by mistake

The hero banner.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.