Magento 2 Image Optimization with WebP and Lazy Load: A Hyvä-Compatible Approach
Optimizing image loading is one of the most impactful ways to improve Magento 2 performance - especially for stores running on Hyvä Themes. In this guide, we’ll walk through practical techniques for implementing lazy loading, WebP support, and responsive image delivery, all while maintaining full compatibility with Hyvä and preserving Core Web Vitals.
Why Image Performance Matters
Images can account for over 60% of total page weight. Unoptimized images delay Largest Contentful Paint (LCP), increase Total Blocking Time (TBT), and contribute to layout shifts. In a Hyvä-based storefront - where JavaScript and CSS are already stripped down - poorly managed images quickly become the bottleneck for performance and SEO.
Hyvä: Frontend Simplicity That Demands Discipline
Hyvä Theme gives developers a clean foundation by removing legacy JS, minimizing CSS, and using Alpine.js and TailwindCSS. This means any third-party assets - including images - must be handled deliberately. There's no place for bloated background sliders, auto-loaded galleries, or oversized hero banners without optimization.
Lazy Load Implementation in Magento 2
Native lazy loading in HTML5 (`loading="lazy"`) is fully supported in Hyvä. When applied to product images, CMS blocks, or banners, it defers image loading until elements enter the viewport. For custom components, use IntersectionObserver
to handle lazy behavior manually.
In Hyvä, lazy loading should be applied via Blade components or custom Alpine directives, ensuring that the markup stays clean and performant.
WebP Support: Smarter Image Delivery
WebP images offer 25–35% smaller file sizes compared to traditional JPEG/PNG without visible quality loss. Magento 2 does not support WebP natively across all image types, but WebP output can be generated during build or deployment using image processing tools (e.g., via CLI or server‑side conversion).
When building Hyvä-based stores, ensure your templates and custom components serve .webp
where possible and gracefully fall back to legacy formats using elements.
Responsive Images and Proper Sizing
Avoid serving 2000px-wide images to a 400px viewport. Use srcset
and sizes
attributes to let browsers pick the optimal image. When working with CMS content or custom sections, apply container-based image constraints using Tailwind utilities (e.g., max-w-md
, object-cover
).
Quality Strategy Without Compromise
Don’t sacrifice quality just to cut file size. Use high-efficiency formats (like WebP), combine with efficient delivery (lazy load, CDN, responsive markup), and test results using Lighthouse or PageSpeed Insights. A Hyvä store can reach sub-1s LCP, but only if images are handled right.
Performance Checklist for Image Optimization
- Use lazy loading via
loading="lazy"
or IntersectionObserver. - Serve WebP images with fallbacks via tags.
- Implement responsive image markup using
srcset
andsizes
. - Optimize image weight server-side during deployment or via CLI.
- Keep above-the-fold images eagerly loaded for faster LCP.
- Test image impact using Core Web Vitals tools and Lighthouse.
Conclusion
In Magento 2, frontend performance depends heavily on how images are loaded and served. For Hyvä-based stores, where every millisecond counts, using lazy loading, WebP, and responsive delivery is not optional - it’s essential.
At qoliber, our performance-first philosophy means every extension we build avoids unnecessary frontend bloat and is engineered to support Core Web Vitals. While we currently do not offer a dedicated image optimization module, we ensure our themes and integrations leave room for clean, efficient image strategies - without conflicts.
As always: minimal assets, clean markup, predictable rendering - that's what keeps your store fast, scalable, and SEO-safe.

Aleksandra "Ola" Czapiewska, née Kijewska
Sorceress of Projects & Wonders
Introducing Ola, a marketing mastermind with nearly two decades of expertise in transforming data into dynamic marketing strategies. Her remarkable track record includes transformative roles at Burda Media Polska, Polska Press Grupa, TIM S.A., and Media Saturn Holding. These positions have seen her launch and lead marketing initiatives that dramatically increased engagement and sales.
A certified Google Partner proficient in top marketing automation platforms like SalesManago and iPresso, Ola has consistently delivered solutions that enhance online visibility and propel business growth.
Currently at qoliber as the 'Sorceress of Projects & Wonders,' she expertly drives projects that surpass expectations, delivering top-notch product quality and securing a formidable market stance.