Overview
Responsive images ensure your website delivers optimally-sized images to every device, reducing page load times and bandwidth usage. The ButterCMS Image API makes this easy through URL-based transformations.Why responsive images matter
- Performance: Smaller images load faster on mobile devices
- Bandwidth: Save data for users on limited connections
- SEO: Google rewards fast-loading pages
- User Experience: Images display correctly across all screen sizes
Basic implementation
Using srcset
Thesrcset attribute lets browsers choose the best image size:
Understanding srcset and sizes
Common patterns
Full-width hero image
Blog Post featured image
Card grid image
Using the picture element
For art direction (different crops for different devices):Framework examples
React component
Vue component
Next.js with next/image
WebP with fallback
Serve WebP to supported browsers with JPEG fallback:Helper functions
JavaScript utility
Best practices
Use Appropriate Sizes
Don’t serve 4K images for thumbnails. Match image sizes to display sizes.
Lazy Loading
Add
loading="lazy" for images below the fold.WebP When Possible
WebP offers 25-35% smaller files than JPEG at similar quality.
Test Performance
Use Lighthouse or WebPageTest to verify image optimization.
Recommended breakpoints
Next steps
Image Transformations
All transformation options
Security
Secure your images
Performance
CDN optimization
Media Field
Working with media fields