PHPackages                             jandc/css-from-html-extractor - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jandc/css-from-html-extractor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jandc/css-from-html-extractor
=============================

Php library which determines which css is used from html snippets.

1.2.0(7y ago)1030.2k↓18.2%21ISCPHPPHP ^5.5 || ^7CI failing

Since Oct 27Pushed 6y ago4 watchersCompare

[ Source](https://github.com/JanDC/css-from-html-extractor)[ Packagist](https://packagist.org/packages/jandc/css-from-html-extractor)[ Docs](https://github.com/JanDC/css-from-html-extractor)[ RSS](/packages/jandc-css-from-html-extractor/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (3)Versions (27)Used By (1)

CSS from HTML extractor
=======================

[](#css-from-html-extractor)

Php library which determines which css is used from html snippets. It is used in jandc/critical-css to automatically and dynamically determine critical css on a per page basis.

### Installation

[](#installation)

`composer require jandc/css-from-html-extractor`

### Usage

[](#usage)

#### With Twig

[](#with-twig)

###### Register Extension

[](#register-extension)

```
use CSSFromHTMLExtractor\Twig\Extension as ExtractorExtension;

$extension = new ExtractorExtension()
$extension->addBaseRules('path/to/css');

/** @var Twig_Environment $twig */
$twig->addExtension($extension);
```

###### Mark the regions of your templates with the provided blocks

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

```
{% fold %}

...

{% endfold %}
```

###### Retrieve the resulting css from the extension

[](#retrieve-the-resulting-css-from-the-extension)

```
$extension = $twigEnvironment->getExtension(ExtractorExtension::class);
$extension->buildCriticalCssFromSnippets();
```

#### Handling raw HTML

[](#handling-raw-html)

```
$cssFromHTMLExtractor = new CssFromHTMLExtractor();
$cssFromHTMLExtractor->addBaseRules('path/to/css');
$cssFromHTMLExtractor->addHtmlToStore($rawHtml);
$extractedCss = $cssFromHTMLExtractor->buildExtractedRuleSet();
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 77.4% 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 ~48 days

Recently: every ~153 days

Total

24

Last Release

2430d ago

Major Versions

0.3.3 → 1.02017-10-20

### 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 (41 commits)")[![tvlooy](https://avatars.githubusercontent.com/u/391674?v=4)](https://github.com/tvlooy "tvlooy (9 commits)")[![gijsroge](https://avatars.githubusercontent.com/u/2242498?v=4)](https://github.com/gijsroge "gijsroge (2 commits)")[![krzysztof-pyrzyk-ah](https://avatars.githubusercontent.com/u/27217899?v=4)](https://github.com/krzysztof-pyrzyk-ah "krzysztof-pyrzyk-ah (1 commits)")

---

Tags

csshtml-extractorphp-library

### Embed Badge

![Health badge](/badges/jandc-css-from-html-extractor/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[metamodels/core

MetaModels core

10156.4k67](/packages/metamodels-core)[contao-community-alliance/dc-general

Universal data container for Contao

1680.8k91](/packages/contao-community-alliance-dc-general)[chameleon-system/chameleon-base

The Chameleon System core.

1028.6k5](/packages/chameleon-system-chameleon-base)[sproutcms/cms

Enterprise content management and framework

242.5k4](/packages/sproutcms-cms)

PHPackages © 2026

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