PHPackages                             wikizeit/html-minifier - 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. wikizeit/html-minifier

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

wikizeit/html-minifier
======================

Lightweight HTML minifier using wikimedia/minify for inline JS/CSS

0.1.0(3w ago)041↓42.9%MITPHPPHP &gt;=8.1CI passing

Since May 14Pushed 3w agoCompare

[ Source](https://github.com/WikiZEIT/HTMLMinifier)[ Packagist](https://packagist.org/packages/wikizeit/html-minifier)[ RSS](/packages/wikizeit-html-minifier/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

HTMLMinifier
============

[](#htmlminifier)

[![packagist](https://camo.githubusercontent.com/b40885c4996584cf8d6c439c4b8934533f9bdce24113f7f2516ee129c1af9d19/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7061636b61676973742d302e312e302d626c75652e737667)](https://packagist.org/packages/wikizeit/html-minifier)[![CI](https://github.com/WikiZEIT/HTMLMinifier/actions/workflows/test.yaml/badge.svg)](https://github.com/WikiZEIT/HTMLMinifier/actions/workflows/test.yaml)[![HTMLMinifier GitHub repo](https://camo.githubusercontent.com/14f8128a463cc567ade29b871a2e56393058b645c4c3259e15cdb58cff136968/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769746875622d48544d4c4d696e69666965722d6f72616e67653f6c6f676f3d676974687562)](https://github.com/WikiZEIT/HTMLMinifier)[![Coverage Status](https://camo.githubusercontent.com/cd9aa633cfb0a65e64020d4b948edad152d32ab42f11a8aef933cbeb43700647/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f57696b695a4549542f48544d4c4d696e69666965722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/WikiZEIT/HTMLMinifier?branch=master)[![LICENSE MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/jcubic/horavox/blob/master/LICENSE)

Lightweight PHP HTML minifier that uses [wikimedia/minify](https://packagist.org/packages/wikimedia/minify) for inline JavaScript and CSS minification.

Features
--------

[](#features)

- Removes HTML comments (with configurable patterns to preserve)
- Collapses whitespace between tags
- Minifies inline `` blocks via Wikimedia's `JavaScriptMinifier`
- Minifies inline `` blocks via Wikimedia's `CSSMin`
- Minifies `application/ld+json` and `application/json` script blocks via `json_encode`(throws on invalid JSON)
- Preserves content in ``, ``, and `` tags
- Preserves IE conditional comments
- Skips other non-JavaScript script types (e.g. `text/template`)

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

[](#installation)

```
composer require wikizeit/html-minifier
```

Usage
-----

[](#usage)

### Static method

[](#static-method)

```
use WikiZEIT\HTMLMinifier;

$minified = HTMLMinifier::minify($html);
```

### Instance with custom preserved comments

[](#instance-with-custom-preserved-comments)

```
use WikiZEIT\HTMLMinifier;

$minifier = new HTMLMinifier();
$minifier->preserveComment('/^\s*my-placeholder\s*$/');
$minified = $minifier->run($html);
```

### With output buffering

[](#with-output-buffering)

```

```

License
-------

[](#license)

Copyright (c) 2026 [Jakub T. Jankiewicz](https://jakub.jankiewicz.org/)

Released under the MIT License. See [LICENSE](https://github.com/WikiZEIT/HTMLMinifier/blob/master/LICENSE) for details.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance94

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

26d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/78985b51e1683b921d5267e309535f1d1591d6ee9072f9aa695a926bad1cb330?d=identicon)[jcubic](/maintainers/jcubic)

---

Top Contributors

[![jcubic](https://avatars.githubusercontent.com/u/280241?v=4)](https://github.com/jcubic "jcubic (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikizeit-html-minifier/health.svg)

```
[![Health](https://phpackages.com/badges/wikizeit-html-minifier/health.svg)](https://phpackages.com/packages/wikizeit-html-minifier)
```

###  Alternatives

[winter/storm

Winter CMS Storm Library

46251.0k6](/packages/winter-storm)[samrap/gestalt

Gestalt is a simple, elegant PHP package for managing your framework's configuration values.

163.6k3](/packages/samrap-gestalt)

PHPackages © 2026

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