PHP code example of zeroseven / critical-css
1. Go to this page and download the library: Download zeroseven/critical-css 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/ */
zeroseven / critical-css example snippets
....
use Zeroseven\CriticalCss\Event\CriticalCssRequierdEvent;
class CriticalCssEventListener
{
public function __invoke(CriticalCssRequierdEvent $event): CriticalCssRequierdEvent
{
if ($event->getRequest()->hasHeader('X-SKIP-CRITICAL-CSS')) {
$event->setRequiered(false);
}
return $event;
}
}