PHP library for generating critical CSS.
- PHP only, no Node.js required.
- Automatically generated for each page
- Manual control through
{% fold %}{% endfold %}
tags - Dynamically resolves CSS used on each page
composer require jandc/critical-css
use TwigWrapper\TwigWrapper;
use CriticalCssProcessor\CriticalCssProcessor;
$twigEnvironment->addExtension(new CSSFromHTMLExtractor\Twig\Extension());
$twigWrapper = new TwigWrapper($twigEnvironment, [new CriticalCssProcessor()]);
{% fold %}
<div class="my-class">
...
</div>
{% endfold %}
$twigWrapper->render('@templates/my/template.twig', ['foo'=>'bar']);
If you have your own implementation, please send a pull request to add it to this list.