https://github.com/nckg/laravel-minify-html
Very, very simple HTML minifier with Laravel support
https://github.com/nckg/laravel-minify-html
html-minifier laravel middleware minifier php
Last synced: about 1 year ago
JSON representation
Very, very simple HTML minifier with Laravel support
- Host: GitHub
- URL: https://github.com/nckg/laravel-minify-html
- Owner: nckg
- Created: 2016-09-26T07:08:04.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2021-02-02T18:32:31.000Z (over 5 years ago)
- Last Synced: 2024-09-17T15:28:48.803Z (almost 2 years ago)
- Topics: html-minifier, laravel, middleware, minifier, php
- Language: PHP
- Size: 19.5 KB
- Stars: 14
- Watchers: 4
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# HTML minifier
[](https://travis-ci.org/nckg/laravel-minify-html) [](https://github.com/nckg/laravel-minify-html) [](https://github.com/nckg/laravel-minify-html) [](https://codecov.io/gh/nckg/laravel-minify-html)
## Introduction
Very, very simple html minifier with Laravel 5.x support.
It _minifies_ HTML by
1. removing HTML comments except IE conditions
2. removing comments
3. shorten multiple white spaces
4. removing whitespaces between HTML tags
5. collapsing new lines
You should end up with a small size profit:
| Uniminfied | Minified |
|------------|----------|
| 64.2KB | 44.6KB |
## Code Samples
```php
$input = "Hello World";
$minifier = new Minifier();
$output = $minifier->html($string); // Hello World
```
## Installation
You can install the package via composer:
``` bash
composer require nckg/laravel-minify-html
```
If you are using Laravel you can add the middleware to your middleware providers
```php
// app/Http/Kernel.php
/**
* The application's global HTTP middleware stack.
*
* @var array
*/
protected $middleware = [
...
\Nckg\Minify\Middleware\MinifyResponse::class,
];
```
## Testing
``` bash
composer test
```
## License
The MIT License (MIT).