
Laravel Blade Minify Directive
github.com/yamadashy/laravel-blade-minify-directive- Category
- Developer Tools
- Rank
- No. 1812Tools index
Previous survey · No. 1820 ·
- Pricing
- Open Source
- Type
- TOOL
- Builder
- yamadashy
- GitHub
- 7 stars
- Latest release
- v1.0.0
- Date
About
Adds a @minify directive to Laravel Blade templates that partially compresses rendered HTML — smaller payloads, same output.
What it does
It lets developers mark chosen Blade template regions for HTML cleanup. Rendering captures each marked region, runs it through an HTML minifier, then inserts the result back into the response.
Why it's ranked here
The narrow scope is the point. Developers can target safe regions instead of risking layout changes across an entire page. Integration tests cover nested and repeated regions, while static analysis runs at its strictest configured level.
What's good
Installation uses Composer, and Laravel discovers the service provider automatically. The directive syntax keeps control beside the affected markup. Tests verify comment removal, whitespace handling, attributes, nesting, multiple regions, compiled templates, and final rendered output.
Tradeoffs
It requires PHP 8.2 or newer and supports only Laravel 11 or 12. Minification happens during rendering through output buffering. Behavior comes from an external HTML minifier, and the repository documents no configuration controls for tuning its transformations.
How to use it well
Use it in Laravel applications where specific Blade fragments contain safely compressible markup. Add marked regions incrementally and test their rendered HTML, especially around whitespace-sensitive content. It does not provide automatic full-page minification or a general asset-compression pipeline.
Technical notes+
composer.json defines a PHP library requiring php ^8.2, laravel/framework ^11.0 || ^12.0, and mrclay/minify ^3.0, with Laravel package discovery registering Yamadashy\MinifyDirective\MinifyDirectiveServiceProvider. src/MinifyDirectiveServiceProvider.php compiles the opening directive to ob_start() and the closing directive to Minifier::minify(ob_get_clean() ?: ''). src/Minifier.php delegates directly to Minify_HTML::minify(). tests/MinifierTest.php checks transformation details, while tests/MinifyDirectiveTest.php exercises compilation, evaluation, nested blocks, repeated blocks, and Blade fixture files. phpstan.neon.dist analyzes src and tests at level 9.
Observed
- License
- MIT License
- Primary language
- PHP
- Package manager
- Composer package yamadashy/laravel-blade-minify-directive
- Interface
- Laravel Blade directives for opening and closing selected regions
- Runtime support
- PHP 8.2 or newer; Laravel 11 or 12
- Core dependency
- mrclay/minify 3.x
- Test structure
- PHPUnit unit and Laravel integration tests are present
- Static analysis
- PHPStan covers source and tests at configured level 9
Read from README.md, composer.json, CLAUDE.md, LICENSE.txt, .tool-versions, phpunit.xml.dist, phpstan.neon.dist, src/Minifier.php, tests/TestCase.php, .github/renovate.json5, tests/MinifierTest.php, .devcontainer/Dockerfile, tests/MinifyDirectiveTest.php, .devcontainer/devcontainer.json, src/MinifyDirectiveServiceProvider.php.
What it can do
Compress HTML output from Blade templates
HTML content within @minify directive → Minified HTML with reduced file size
Reduce webpage payload size
Laravel Blade template with @minify directive → Smaller HTML payload for faster loading
Remove unnecessary whitespace from HTML
HTML markup within Blade template → Compressed HTML without extra spaces and line breaks
Optimize HTML for web delivery
Blade template markup → Bandwidth-optimized HTML content
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.