PHPackages                             arjanschouten/htmlminifier - 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. arjanschouten/htmlminifier

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

arjanschouten/htmlminifier
==========================

PHP based Html minifier with support for Laravel/Lumen. This minifier will improve you're application size drastically!

0.0.2(10y ago)239461[3 issues](https://github.com/ArjanSchouten/HtmlMinifier/issues)MITPHPPHP &gt;=5.6

Since Oct 14Pushed 8y ago5 watchersCompare

[ Source](https://github.com/ArjanSchouten/HtmlMinifier)[ Packagist](https://packagist.org/packages/arjanschouten/htmlminifier)[ RSS](/packages/arjanschouten-htmlminifier/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (5)Used By (0)

> This package is still in Beta version! Use it with care!

HtmlMinifier
============

[](#htmlminifier)

[![Build Status](https://camo.githubusercontent.com/36624ed6202f4e8c543ed873f1f57b0ca2f578d83502794d1b4d0d7868ae0eb2/68747470733a2f2f7472617669732d63692e6f72672f41726a616e5363686f7574656e2f48746d6c4d696e69666965722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ArjanSchouten/HtmlMinifier)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5a87e94196a192128f1b0f3be0c98edc8f34a5b41fce978e14f07d7261e39338/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f41726a616e5363686f7574656e2f48746d6c4d696e69666965722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ArjanSchouten/HtmlMinifier/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/3baf0f1f263495b3925add3b11cc2a8e11a76d7dd6f3065d10bc50a54ff676bf/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f41726a616e5363686f7574656e2f48746d6c4d696e69666965722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ArjanSchouten/HtmlMinifier/?branch=master)

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

[](#installation)

Let composer do the hard work for us!

```
composer require arjanschouten/htmlminifier
```

#### Laravel 5.\*

[](#laravel-5)

A Laravel package based on this minifier can be installed by running:

```
composer require arjanschouten/laravelhtmlminifier
```

#### Plain php projects with composer

[](#plain-php-projects-with-composer)

If you're not using a php framework you can use the minifier by using the code below:

```
//include the composer autoloader
require __DIR__ . '/vendor/autoload.php';

// create a minify context which will be used through the minification process
$context = new MinifyContext(new PlaceholderContainer());
// save the html contents in the context
$context->setContents('My html...');
$minify = new Minify();
// start the process and give the context with it as parameter
$context = $minify->run($context);

// $context now contains the minified version
$minifiedContents = $context->getContents();
```

Options
-------

[](#options)

This minifier have some minification options which are:

Minification strategyOption NameEnabled by defaultRemove redundant whitespaceswhitespacesyesRemove commentscommentsyesCollapse boolean attributes from checked="checked" to checkedboolean-attributesyesRemove quotes around html attributesremove-attributequotesnoRemove optional elements which can be implied by the browseroptional-elementsnoRemove defaults such as from ``remove-defaultsnoRemove empty attributes. HTML boolean attributes are skippedremove-empty-attributesnoYou can enable the various minification options for example with:

```
...
$options = [
  'whitespace' => false,
  'remove-defaults' => true,
];

$minify->run($context, $options);
```

This will disable `whitespace` and enables `remove-defaults`.

### Contributing

[](#contributing)

**Contributions are welcome**. Please read the [CONTRIBUTING.md readme](https://github.com/ArjanSchouten/HtmlMinifier/blob/master/CONTRIBUTING.md).

### Testing

[](#testing)

HtmlMinifier uses `phpunit` for testing. You can run the tests with `vendor/bin/phpunit `.

### License

[](#license)

This package is licensed under the [MIT License](https://github.com/ArjanSchouten/HtmlMinifier/blob/master/LICENSE).

### Creator and Maintainer

[](#creator-and-maintainer)

This package is created and maintained by [Arjan Schouten](http://arjan-schouten.nl).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.9% 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 ~79 days

Total

3

Last Release

3710d ago

PHP version history (2 changes)0.0.0PHP &gt;=5.5

0.0.1PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/e9f9c42fedf09f0459375a8c16ca3b9f90c68dee979dadc8a33d003dc53d0462?d=identicon)[ArjanSchouten](/maintainers/ArjanSchouten)

---

Top Contributors

[![ArjanSchouten](https://avatars.githubusercontent.com/u/5930718?v=4)](https://github.com/ArjanSchouten "ArjanSchouten (126 commits)")[![flo-sch](https://avatars.githubusercontent.com/u/1577155?v=4)](https://github.com/flo-sch "flo-sch (4 commits)")

---

Tags

htmlminifierhtml minifierlaravel html minifierlumen html minifierhtml compressor

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arjanschouten-htmlminifier/health.svg)

```
[![Health](https://phpackages.com/badges/arjanschouten-htmlminifier/health.svg)](https://phpackages.com/packages/arjanschouten-htmlminifier)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[htmlmin/htmlmin

HTMLMin Is A Simple HTML Minifier For Laravel 5

1.0k1.9M9](/packages/htmlmin-htmlmin)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[illuminate/session

The Illuminate Session package.

9937.4M753](/packages/illuminate-session)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)

PHPackages © 2026

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