PHPackages                             jandc/critical-css - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. jandc/critical-css

ActiveLibrary

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

0.6.1(8y ago)3711.6k2[4 issues](https://github.com/JanDC/critical-css/issues)1MITPHP

Since Nov 23Pushed 8y ago4 watchersCompare

[ Source](https://github.com/JanDC/critical-css)[ Packagist](https://packagist.org/packages/jandc/critical-css)[ RSS](/packages/jandc-critical-css/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (4)Versions (20)Used By (1)

Critical CSS
============

[](#critical-css)

PHP library for generating critical CSS.

[![critical css banner](https://camo.githubusercontent.com/7c6e5f664d9e594fe3b769d70c1825a683e7ecce64b5e35439a516e72516654e/68747470733a2f2f637269746963616c2d6373732e6a616e64632e696f2f696d616765732f62616e6e65722e6a7067)](https://camo.githubusercontent.com/7c6e5f664d9e594fe3b769d70c1825a683e7ecce64b5e35439a516e72516654e/68747470733a2f2f637269746963616c2d6373732e6a616e64632e696f2f696d616765732f62616e6e65722e6a7067)

Features
--------

[](#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
--------------------------

[](#sites-using-critical-css)

-

Installation
------------

[](#installation)

`composer require jandc/critical-css `

##### Register the twig extension and create a wrapper instance with the critical CSS processor

[](#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

[](#mark-the-regions-of-your-templates-with-the-provided-blocks)

```
{% fold %}

    ...

{% endfold %}
```

##### Render your pages, using the twigwrapper

[](#render-your-pages-using-the-twigwrapper)

```
 $twigWrapper->render('@templates/my/template.twig', ['foo'=>'bar']);
```

Available implementations
-------------------------

[](#available-implementations)

- [Silex](https://github.com/JanDC/critical-css-silex)

If you have your own implementation, please send a pull request to add it to this list.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 83.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Recently: every ~13 days

Total

19

Last Release

2995d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3265146?v=4)[Jan Decavele](/maintainers/jandc)[@JanDC](https://github.com/JanDC)

---

Top Contributors

[![JanDC](https://avatars.githubusercontent.com/u/3265146?v=4)](https://github.com/JanDC "JanDC (31 commits)")[![gijsroge](https://avatars.githubusercontent.com/u/2242498?v=4)](https://github.com/gijsroge "gijsroge (6 commits)")

### Embed Badge

![Health badge](/badges/jandc-critical-css/health.svg)

```
[![Health](https://phpackages.com/badges/jandc-critical-css/health.svg)](https://phpackages.com/packages/jandc-critical-css)
```

###  Alternatives

[dompdf/dompdf

DOMPDF is a CSS 2.1 compliant HTML to PDF converter

11.1k169.8M608](/packages/dompdf-dompdf)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)[code16/sharp

Laravel Content Management Framework

78959.5k4](/packages/code16-sharp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
