jandc/critical-css
Composer 安装命令:
composer require jandc/critical-css
包简介
Package wrapper and twig postprocessor class which uses the 'css from html extractor' library and twigwrapper to inject a document's head with critical css
README 文档
README
PHP library for generating critical CSS.
Features
- PHP only, no Node.js required.
- Automatically generated for each page
- Manual control through
{% fold %}{% endfold %}tags - Dynamically resolves CSS used on each page
Site(s) using Critical CSS
Installation
composer require jandc/critical-css
Register the twig extension and create a wrapper instance with the critical CSS processor
use TwigWrapper\TwigWrapper; use CriticalCssProcessor\CriticalCssProcessor; $twigEnvironment->addExtension(new CSSFromHTMLExtractor\Twig\Extension()); $twigWrapper = new TwigWrapper($twigEnvironment, [new CriticalCssProcessor()]);
Mark the regions of your templates with the provided blocks
{% fold %}
<div class="my-class">
...
</div>
{% endfold %}
Render your pages, using the twigwrapper
$twigWrapper->render('@templates/my/template.twig', ['foo'=>'bar']);
Available implementations
If you have your own implementation, please send a pull request to add it to this list.
统计信息
- 总下载量: 11.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 38
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-20