https://github.com/abordage/laravel-html-min
HtmlMin is very simple (and very fast) html compression package for Laravel
https://github.com/abordage/laravel-html-min
html-minifier laravel-htmlmin
Last synced: 6 months ago
JSON representation
HtmlMin is very simple (and very fast) html compression package for Laravel
- Host: GitHub
- URL: https://github.com/abordage/laravel-html-min
- Owner: abordage
- License: mit
- Created: 2022-06-13T06:54:12.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-02-27T11:44:45.000Z (over 1 year ago)
- Last Synced: 2025-02-27T16:13:26.608Z (over 1 year ago)
- Topics: html-minifier, laravel-htmlmin
- Language: PHP
- Homepage:
- Size: 86.9 KB
- Stars: 22
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# HtmlMin: Laravel package for HTML minification
Very simple (and very fast) html compression.
## Features
- Removing extra whitespaces
- Removing html comments (works correctly with `livewire/livewire` comments)
- Removing trailing slashes from void elements (HTML5)
- Skip `textarea`, `pre` and `script` elements
- Very fast. See benchmark
## Requirements
- PHP 7.4 or higher (7.4, 8.0, 8.1, 8.2, 8.3, 8.4)
- Laravel 8.x - 12.x
## Installation
You can install the package via composer:
```bash
composer require abordage/laravel-html-min
```
You can publish the config file with:
```bash
php artisan vendor:publish --tag="html-min-config"
```
## Usage
To enable compression just register middleware:
```php
// app/Http/Kernel.php
protected $middleware = [
'web' => [
// other middleware
\Abordage\LaravelHtmlMin\Middleware\HtmlMinify::class,
],
// ...
];
```
It's all. Optionally you can change the settings in `config/html-min.php`
## Configuration
| Option | Default | Description |
|-----------------------------------------|---------|----------------------------------------|
| `enable` | `true` | Enable/disable HTML minification |
| `find_doctype_in_document` | `true` | Skip minification if DOCTYPE not found |
| `remove_whitespace_between_tags` | `true` | Remove whitespace between tags |
| `remove_blank_lines_in_script_elements` | `false` | Remove blank lines in `` |
| `remove_trailing_slashes` | `false` | Convert `<link />` to `<link>` |
See `config/html-min.php` for detailed descriptions.
## Benchmark
See [abordage/html-min-benchmark](https://github.com/abordage/html-min-benchmark)
## Testing
```bash
composer test:all
```
or
```bash
composer test:phpunit
composer test:phpstan
composer test:phpcsf
```
or see https://github.com/abordage/laravel-html-min/actions/workflows/tests.yml
## Feedback
If you have any feedback, comments or suggestions, please feel free to open an issue within this repository.
## Contributing
Please see [CONTRIBUTING](https://github.com/abordage/.github/blob/master/CONTRIBUTING.md) for details.
## Credits
- [Pavel Bychko](https://github.com/abordage)
- [All Contributors](https://github.com/abordage/laravel-html-min/graphs/contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.