Very simple (and very fast) html compression.
- Removing extra whitespaces
- Removing html comments (works correctly with
livewire/livewirecomments) - Skip
textarea,preandscriptelements - Very fast. See benchmark
- PHP 7.4 - 8.3
- Laravel 8.x - 11.x
You can install the package via composer:
composer require abordage/laravel-html-minYou can publish the config file with:
php artisan vendor:publish --tag="html-min-config"To enable compression just register middleware:
// 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
return [
/*
|--------------------------------------------------------------------------
| Enable Html Min
|--------------------------------------------------------------------------
*/
'enable' => env('HTML_MINIFY', true),
/*
|--------------------------------------------------------------------------
| Find DOCTYPE in document
|--------------------------------------------------------------------------
*/
'find_doctype_in_document' => true,
/*
|--------------------------------------------------------------------------
| Remove whitespace between tags
|--------------------------------------------------------------------------
*/
'remove_whitespace_between_tags' => true,
/*
|--------------------------------------------------------------------------
| Remove blank lines in script elements
|--------------------------------------------------------------------------
*/
'remove_blank_lines_in_script_elements' => false,
];See abordage/html-min-benchmark
composer test:allor
composer test:phpunit
composer test:phpstan
composer test:phpcsfor see https://github.com/abordage/laravel-html-min/actions/workflows/tests.yml
If you have any feedback, comments or suggestions, please feel free to open an issue within this repository.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.