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

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

nguyenhiep/tiny-html-minifier
=============================

Minify HTML in PHP with just a single class

0151PHP

Since Jun 4Pushed 5y agoCompare

[ Source](https://github.com/nguyenhiepvan/tiny-html-minifier)[ Packagist](https://packagist.org/packages/nguyenhiep/tiny-html-minifier)[ RSS](/packages/nguyenhiep-tiny-html-minifier/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Tiny Html Minifier
==================

[](#tiny-html-minifier)

[![Version 2.2](https://camo.githubusercontent.com/add10f42f0179bb6907eee3a3e591367be9e5cdc26624ff5a451f795f17434e3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d322e322d626c75652e737667)](https://camo.githubusercontent.com/add10f42f0179bb6907eee3a3e591367be9e5cdc26624ff5a451f795f17434e3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d322e322d626c75652e737667) [![MIT license](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667) [![Donate](https://camo.githubusercontent.com/2ee2c3802ed26d0340f0a534dbeb31e9fcbcbe2acf8333f8e45fdcc73ae83bf5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f676976652d646f6e6174696f6e2d79656c6c6f772e737667)](https://www.paypal.me/DevoneraAB)

[Changelog](changelog.md)

In short
--------

[](#in-short)

- A HTML minifier in PHP.
- It's really really fast.
- Only 1 file is required.
- Almost no regular expressions.
- Almost no options.

Details - What the minifier does
--------------------------------

[](#details---what-the-minifier-does)

- Remove HTML comments.
- Remove slash in self closing elements. ` />` becomes `>`.
- Remove ` type="text/css"` and `type="text/javascript"` in `style` and `script` tags.
- Minimize elements within ``. It will not keep any whitespace (except inside `script`).
- Minimize elements within `` but keep spaces between tags to preserve inline data (optional).
- Minimize inline SVG files (which are a bunch of XML tags).
- Minimize Custom Elements. They look like this: `My content`.
- Skip `code`, `pre`, `script` and `textarea` from being minified.

Install &amp; usage
-------------------

[](#install--usage)

### 1. Download

[](#1-download)

**ZIP**

Download `tiny-html-minifier.php` or the whole ZIP.

**Composer**

You can install it with Composer as well.

### 2. Add the code

[](#2-add-the-code)

```
