friends-of-hyva / magento2-preload-images
friends-of-hyva/magento2-preload-images
Preload images above the fold to improve performance metrics.
Preload Images via HTTP Link response header
This module was built as an experiment during the MageUnConf Hackathon in Cologne, in September 2022.
The goal is to improve the user experience by loading images that are guaranteed to be displayed above the fold earlier.
The idea came out of interesting discussions with Tsvetan Stoychev and his experience working at Akamai on the frontend performance team.
Installation
Run the command
composer require friends-of-hyva/magento2-preload-images
Usage:
Import the Hyva\PreloadImages\ViewModel\PreloadImages view model into your template and call the add() method, passing the image URL string as a parameter.
In Hyvä the ViewModelRegistry can be used, with Luma based themes the view model has to be passed into the template as a block argument using Layout XML.
Hyvä Example:
/** @var string $imageUrl */
$viewModels->require($viewModels->require(PreloadImages::lass)->add($mainImageData);::class)->add($imageUrl);
Details
The preloading is triggered in the browser by a Link header.
Take this screenshot of a PDP waterfall chart on slow 3G without preloading:
[image: Load times waterfall chart of a PDP without preloading]
You can see the main product image wp13-orange_maim_1.jpg begins loading shortly after the protia-capri.html document is received.
The browser requests the main product image after the css files used by the page.
Here is the screenshot of the same page with preloading:
[image: Load times waterfall chart of a PDP with preloading]
With preloading, the browser requests the main product image before even the css files.
Be aware!
The feature this module provides is well in the range of micro-optimization, and if used without care can harm a websites SEO metrics.
If preloading an image improves the customer experience or a search engine ranking metric really depends on the site in question and the customer usage base.
Also, it will require a relatively high amount of visitors and careful monitoring to determine if it improves the situation for the majority of visitors.
License
Copyright 2022 Vinai Kopp & Hyvä Themes BV
The module is released under the BSD-3 Clause license.
No changelog yet
The vendor hasn't published a changelog. Tagged releases appear in the Versions tab.
No dependencies declared
This package's composer.json doesn't declare any required, suggested, replaced, or conflicting packages.
Compatibility
Each Magento release line is installed on its supported PHP versions, then the module is built (DI compilation + static-content deploy) and its unit and integration suites are run. The matrix shows the lines and PHP versions the module is confirmed to install and run on. Code-quality results further down (phpstan, phpcs, …) are reported separately and never affect compatibility.
Code Quality
Advisory checks against the module's source. Static analysis runs once across the whole module; PHPStan re-runs per Magento + PHP version because resolvable symbols differ between releases. These NEVER affect the Compatibility badge — a phpcs finding can't make a module incompatible.
Static analysis
Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.
PHPStan
Type-checks the module's PHP against a real Magento install at the configured gate level. Re-runs per Magento and PHP version because resolvable symbols differ between releases. Cell → details modal.
Tests
Unit and integration suites, run for each applicable Magento and PHP version. A test failure speaks to the module's behaviour, not its compatibility with a Magento line, so it is reported here separately and never reddens the compatibility matrix.
Unit tests
| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | ||
| 2.4.8 | N/A | N/A | ||
| 2.4.9 | N/A | N/A |
Integration tests
| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | ||
| 2.4.8 | N/A | N/A | ||
| 2.4.9 | N/A | N/A |
Security
Security checks run directly against the module: an audit of its declared dependencies for known vulnerabilities (composer audit) and a scan of its source for malware and web-shell signatures. Each runs once. A malware detection fails the version outright.
Turn an existing module into recurring revenue.
If you already maintain a Magento 2 module on GitHub or GitLab, listing it on Packagento takes about five minutes. We mirror your tags, handle distribution signing, and route paid licenses through Stripe Connect, so you can keep shipping the way you already do.