PHP code example of blackbird / module-link-header

1. Go to this page and download the library: Download blackbird/module-link-header library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

blackbird / module-link-header example snippets



use Blackbird\LinkHeader\ViewModel\LinkHeader;

/** @var \Hyva\Theme\Model\ViewModelRegistry $viewModels */
$viewModels->


$viewModels->oadHeader($mobileUrl, ['media' => '(max-width: 767.98px)', 'fetchpriority' => 'high'])
    ->addImagePreloadHeader($desktopUrl, ['media' => '(min-width: 768px)', 'fetchpriority' => 'high']);


$viewModels->r('https://www.googletagmanager.com', ['rel' => 'preconnect', 'crossorigin' => '']);

 $block->getData('link_header')->addImagePreloadHeader($imageUrl); 
bash
php bin/magento setup:upgrade