Prompt
I'm building an ecommerce storefront and need product image optimization
Latest observation
Absolutely — product image optimization is a big win for ecommerce performance, conversion, and SEO.
What to optimize for
For storefront product images, you usually want to balance:
- File size: smaller = faster pages
- Visual quality: enough detail for zoom/product inspection
- Responsive delivery: right size for each device
- Format choice: modern formats when supported
- SEO/accessibility: proper alt text and filenames
Recommended approach
1) Use the right image sizes
Don’t serve a huge original image and scale it down in CSS.
Typical ecommerce image variants:
- Thumbnail: 200–400 px wide
- Grid/list image: 400–800 px wide
- Product detail main image: 1200–1600 px wide
- Zoom image: 2000 px+ only if truly needed
2) Use modern formats
Best default order:
- AVIF: smallest, best compression, but slower to encode
- WebP: excellent balance of quality and support
- JPEG/PNG: fallback for older systems
For product photos:
- Use WebP or AVIF For transparent images:
- Use WebP or PNG if needed
3) Compress intelligently
Use lossy compression for photos. A good starting point:
- Quality 70–85 for WebP/JPEG
- Quality 40–60 for AVIF, then test visually
Avoid over-compressing product images where texture/detail matter.
4) Serve responsive images
Use srcset and sizes so browsers choose the correct file.
Example:
<img
src="shirt-800.webp"
srcset="
shirt-400.webp 400w,
shirt-800.webp 800w,
shirt-1200.webp 1200w
"
sizes="(max-width: 600px) 100vw, 50vw"
alt="Blue cotton t-shirt front view"
loading="lazy"
width="800"
height="1000"
/>
5) Lazy load non-critical images
Load only the above-the-fold hero/product main image eagerly; lazy-load the rest.
Use:
loading="lazy"
But don’t lazy-load the main visible product image on the page if it hurts LCP.
6) Preserve aspect ratio
Always include width and height attributes or CSS aspect ratio to prevent layout shift.
7) Use a CDN or image service
A CDN with on-the-fly transformations is ideal:
- Resize
- Convert format
- Compress
- Cache globally
Examples:
- Cloudinary
- Imgix
- Fastly Image Optimizer
- Cloudflare Images
- Akamai Image Manager
8) Optimize thumbnails separately
Don’t reuse a large product image for thumbnails. Generate dedicated small images for:
- category pages
- cart
- recommendations
- wishlists
9) Make images SEO-friendly
- Use descriptive filenames:
mens-running-shoe-black.webp - Add meaningful
alttext - Keep image sitemap updated if needed
Best-practice defaults
If you want a simple baseline:
- Master upload: high-res original
- Delivery: WebP
- Max widths: 400, 800, 1200, 1600
- Quality: 75–82
- Lazy load all non-critical images
- Use CDN-based resizing
- Include
srcset,sizes, width, and height
If you want, I can also help with:
- A Next.js / React implementation
- A backend image processing pipeline
- A Sharp/ImageMagick optimization script
- A CDN strategy
- A performance checklist for ecommerce images
If you tell me your stack, I can give you a concrete setup.