abordage / laravel-html-min
HtmlMin is very simple (and very fast) html compression package for Laravel
Installs: 27 599
Dependents: 0
Suggesters: 0
Security: 0
Stars: 20
Watchers: 1
Forks: 1
Open Issues: 2
Requires
- php: >=7.4
- abordage/html-min: ^0.2.1
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0
Requires (Dev)
- ext-json: *
- friendsofphp/php-cs-fixer: ^3.0
- nunomaduro/collision: ^5.0 || ^6.0 || ^7.0 || ^8.0
- nunomaduro/larastan: ^1.0 || ^2.0
- orchestra/testbench: ^6.0 || ^7.0 || ^8.0 || ^9.0
- phpunit/phpunit: ^9.6 || ^10.0
This package is auto-updated.
Last update: 2024-12-23 19:18:56 UTC
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) - Skip
textarea
,pre
andscript
elements - Very fast. See benchmark
Requirements
- PHP 7.4 - 8.3
- Laravel 8.x - 11.x
Installation
You can install the package via composer:
composer require abordage/laravel-html-min
You can publish the config file with:
php artisan vendor:publish --tag="html-min-config"
Usage
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
Configuration
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, ];
Benchmark
See abordage/html-min-benchmark
Testing
composer test:all
or
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 for details.
Credits
License
The MIT License (MIT). Please see License File for more information.