Native lazy loading
`loading="lazy"` attribute injected via PHP plugin on product images (zero JS required, best compatibility)
Frontend image performance for Magento 2 - lazy loading (Native / IntersectionObserver / Hybrid), WebP browser detection with PNG/JPG fallback, <link rel="preload"> hints for critical images, async decoding, and fetchpriority="high" for LCP candidates. Compatible with Magento ...
Key Features:
Additional Services
Built-in from day one. No add-ons, no upsell, no licence keys to renew.
`loading="lazy"` attribute injected via PHP plugin on product images (zero JS required, best compatibility)
JavaScript-based lazy loading with fade-in effect, configurable pixel threshold, and placeholder support
combine both strategies for maximum browser coverage
skip lazy loading for the first N images to protect LCP
Panth Image Optimizer is a frontend image performance extension for Magento 2 and Adobe Commerce that targets Core Web Vitals with lazy loading, WebP detection, and preload hints.
The Panth Image Optimizer extension ships three complementary lazy-loading strategies for Magento 2: Native (loading="lazy" attribute injected via a PHP plugin), IntersectionObserver (JavaScript-based with fade-in, configurable threshold, and above-the-fold exclusion), and Hybrid (both together for maximum browser coverage), so stores can pick the strategy that fits their traffic profile.
It is built for Magento 2 merchants and Hyvä agencies who want measurable LCP, CLS, and INP improvements without changing storage, CDN, or image-generation pipelines. Client-side WebP detection strips <source type="image/webp"> elements from <picture> tags when the browser cannot render WebP, so PNG and JPG fallbacks load automatically.
Performance hints round out the optimization layer: <link rel="preload" as="image"> tags for critical above-the-fold images, decoding="async" on all images so the browser decodes off the main thread, and fetchpriority="high" on LCP candidates (Chrome 101+). It is purely a frontend layer and works on top of any existing image pipeline.
Best for:
Panth Image Optimizer combines lazy loading, WebP fallback, and preload hints to optimize Magento 2 image delivery and Core Web Vitals.
Frontend image performance for Magento 2 — lazy loading (Native / IntersectionObserver / Hybrid), WebP browser detection with PNG/JPG fallback,
<link rel="preload">hints for critical images, async decoding, andfetchpriority="high"for LCP candidates. Compatible with Magento 2.4.4 – 2.4.8, PHP 8.1 – 8.4, Hyva and Luma themes.
Panth Image Optimizer is a lightweight, frontend-focused Magento 2 extension that improves image delivery performance and directly targets Core Web Vitals (LCP, CLS, INP). It ships three complementary lazy-loading strategies — Native (loading="lazy" attribute injected via PHP plugin), IntersectionObserver (JS-based with fade-in, configurable threshold, and above-the-fold exclusion), and Hybrid (both together for maximum coverage). It also includes client-side WebP detection: when the visitor's browser cannot render WebP, <source type="image/webp"> elements are stripped from <picture> tags so the browser falls back to PNG/JPG automatically. On top of that, the module injects <link rel="preload" as="image"> for critical above-the-fold images, sets decoding="async" on all images so the browser decodes them off the main thread, and applies fetchpriority="high" to LCP candidates (Chrome 101+).
This module does not perform server-side WebP conversion, CDN rewriting, or srcset/sizes generation — it is purely a frontend performance layer that works on top of whatever image pipeline you already have. Perfect for merchants who want measurable Core Web Vitals improvements without changing their storage, CDN, or image-generation setup.
loading="lazy" attribute injected via PHP plugin on product images (zero JS required, best compatibility)<source type="image/webp"> from <picture> elements so the browser loads PNG/JPG fallbacks<link rel="preload" as="image"> for the first N images on the page (LCP booster)decoding="async" to all images so decode work happens off the main thread (improves INP)Stores → Configuration → Panth Extensions → Image OptimizerPanth Image Optimizer operates purely on the frontend layer:
loading="lazy", decoding="async", and fetchpriority attributes to product image markup during HTML generation.canvas.toDataURL('image/webp')) and caches the result<source> tags when WebP is not availableIntersectionObserver that swaps data-src → src when images near the viewport<link rel="preload" as="image"> for the first N critical imagesWhat this module does NOT do:
srcset / sizes) rewritingloading="lazy")The simplest and most compatible approach. A PHP plugin injects the loading="lazy" attribute on product images during HTML rendering. No JavaScript required, supported in all modern browsers.
Best for: stores with minimal JS overhead, Hyva storefronts, or sites that prioritize server-rendered HTML.
A JavaScript loop watches images and swaps data-src → src when they near the viewport. Supports fade-in effects, placeholders, and configurable thresholds.
Best for: stores that want a smooth fade-in UX, older browsers, or granular control over when images load.
Applies native loading="lazy" as the baseline and layers IntersectionObserver on top for enhanced UX (fade-in, blur placeholder). Maximum compatibility and UX.
Best for: most production stores — recommended default.
On page load, a short JavaScript snippet tests WebP support:
const webp = new Image();
webp.onload = webp.onerror = () => {
document.documentElement.classList.toggle('webp', webp.height === 2);
};
webp.src = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=';
When WebP is not supported, the module walks the DOM and removes <source type="image/webp"> elements from <picture> tags. The browser then loads the <img> fallback (PNG/JPG) automatically.
Note: this module does not generate WebP files on the server. Use a dedicated WebP-generation module or a CDN (Cloudflare Polish, Fastly IO, Bunny Optimizer) to produce WebP sources. Panth Image Optimizer handles the client-side fallback layer.
On every page, the module injects <link rel="preload" as="image"> tags into the <head> for the first N images (configurable). This tells the browser to fetch LCP candidates in parallel with the HTML, dramatically reducing LCP on product and category pages.
All images receive decoding="async", which tells the browser to decode images off the main thread. This reduces blocking time and improves INP (Interaction to Next Paint).
LCP candidates receive fetchpriority="high", hinting the browser (Chrome 101+) to prioritize them in the network queue ahead of lower-priority assets. Combined with preload, this is the single biggest LCP win available today.
Ready to make your Magento 2 store faster?
SEO Keywords: magento 2 image optimization, magento 2 lazy loading, webp magento, magento 2 webp fallback, magento 2 webp detection, image performance magento, core web vitals images, magento 2 LCP optimization, magento 2 fetchpriority, magento 2 preload images, magento 2 async decoding, magento 2 intersectionobserver lazy loading, magento 2 native lazy loading, hyva image optimizer, luma image optimizer, magento 2 picture element, magento 2 image performance extension, magento 2 core web vitals module, magento 2.4.8 image optimization, php 8.4 magento image, magento 2 page speed, magento 2 LCP booster, panth image optimizer, panth infotech, mage2kishan, mage2sk, hire magento performance developer, top rated plus magento freelancer, kishan savaliya magento, magento 2 image lazy load plugin, magento 2 WebP browser detection, magento 2 image fade-in, magento 2 image placeholder, magento 2 above the fold images, magento 2 image preload link
| Requirement | Versions Supported |
|---|---|
| Magento Open Source | 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8 |
| Adobe Commerce | 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8 |
| Adobe Commerce Cloud | 2.4.4 — 2.4.8 |
| PHP | 8.1.x, 8.2.x, 8.3.x, 8.4.x |
| Hyva Theme | 1.3+ (fully compatible) |
| Luma Theme | Native support |
| Required Dependency | mage2kishan/module-core (free) |
Tested on:
composer require mage2kishan/module-imageoptimizer
bin/magento module:enable Panth_Core Panth_ImageOptimizer
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy -f
bin/magento cache:flush
app/code/Panth/ImageOptimizer/ in your Magento installation.Panth_Core is installed (free dependency).bin/magento module:enable.bin/magento module:status Panth_ImageOptimizer
# Expected output: Module is enabled
Then navigate to:
Admin → Stores → Configuration → Panth Extensions → Image Optimizer
All settings are at Stores → Configuration → Panth Extensions → Image Optimizer.
| Setting | Default | Description |
|---|---|---|
| Enable Image Optimizer | Yes | Master switch for all frontend optimizations. |
| Enable Debug Mode | No | Log optimization activity to the browser console. Disable in production. |
| Setting | Default | Description |
|---|---|---|
| Enable WebP Detection | Yes | Detect browser WebP support via JavaScript. |
| Enable Fallback Behavior | Yes | Strip <source type="image/webp"> tags when WebP is unsupported so the browser loads PNG/JPG. |
| Setting | Default | Description |
|---|---|---|
| Enable Lazy Loading | Yes | Defer offscreen images until they approach the viewport. |
| Loading Strategy | Hybrid | Native / IntersectionObserver / Hybrid. |
| Threshold (pixels) | 200 | Start loading images N pixels before viewport (IntersectionObserver only). |
| Placeholder Type | Blur | Visual placeholder while an image loads (IntersectionObserver only). |
| Enable Fade-In Effect | Yes | Smooth opacity transition when images finish loading. |
| Exclude Above-the-Fold Images | Yes | Skip lazy loading for the first N images (protects LCP). |
| Exclude First N Images | 3 | Number of images at the top of the page to load immediately. |
| Setting | Default | Description |
|---|---|---|
| Preload Critical Images | Yes | Inject <link rel="preload" as="image"> for the first N images. |
| Preload Image Count | 1 | Number of images to preload (recommended: 1–2). |
| Async Image Decoding | Yes | Add decoding="async" to all images. |
| Use fetchpriority Attribute | Yes | Set fetchpriority="high" on LCP candidates (Chrome 101+). |
| Module Category | Performance |
|---|---|
| Best For | All Sizes |
Talk to Kishan directly — written quote, scope and timeline within 24 hours. No sales call.
Image Optimizer for Magento 2