https://github.com/samjuk/m2-module-fetch-priority
[WIP]
https://github.com/samjuk/m2-module-fetch-priority
Last synced: 4 months ago
JSON representation
[WIP]
- Host: GitHub
- URL: https://github.com/samjuk/m2-module-fetch-priority
- Owner: SamJUK
- License: mit
- Created: 2025-02-24T10:58:25.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2026-01-12T12:10:26.000Z (5 months ago)
- Last Synced: 2026-01-12T19:12:11.630Z (5 months ago)
- Language: PHP
- Homepage:
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SamJUK_FetchPriority
[](https://github.com/SamJUK/m2-module-fetch-priority/actions/workflows/ci.yml)
[](https://github.com/SamJUK/m2-module-fetch-priority/actions/workflows/ci.yml)
[](https://github.com/SamJUK/m2-module-fetch-priority/releases)
This module adds options to set the fetch priority & lazy loading attribute on images added via the admin area.
It also provides a simple API to add preload & prefetch link tags to the header from other modules.
## Installation
```sh
composer require samjuk/m2-module-fetch-priority
php bin/magento setup:upgrade && php bin/magento cache:flush
```
## Link Tag Usage
To use this module to add preload/prefetch link tags
### Example Preload Usage
```php
class MyClassToAddPreloads
{
public function __construct(
private readonly \SamJUK\FetchPriority\Model\LinkStore $linkStore,
private readonly \SamJUK\FetchPriority\Model\Links\PreloadFactory $preloadFactory
) { }
public function execute()
{
// Do Stuff
$preload = $this->preloadFactory->create([
'href' => 'https://app.magento2.test/media/my_custom_entity/image1.jpg',
'mimeType' => \SamJUK\FetchPriority\Enum\Preload\MimeType::ImageJPEG,
'asType' => \SamJUK\FetchPriority\Enum\Preload\AsType::Image,
'fetchPriority' => \SamJUK\FetchPriority\Enum\FetchPriority::High
]);
$this->linkStore->add($preload);
}
}
```
### Example Prefetch Usage
```php
class MyClassToAddPrefetches
{
public function __construct(
private readonly \SamJUK\FetchPriority\Model\LinkStore $linkStore,
private readonly \SamJUK\FetchPriority\Model\Links\PrefetchFactory $preloadFactory
) { }
public function execute()
{
// Do Stuff
$prefetch = $this->preloadFactory->create([
'href' => 'https://app.magento2.test/media/my_custom_entity/image1.jpg',
]);
$this->linkStore->add($prefetch);
}
}
```