A modern HTML minification addon for Statamic v5 that automatically compresses your website's HTML output, reducing page load times and bandwidth usage.
- Automatic HTML Minification: Compresses HTML on every request via middleware
- Statamic v5 Compatible: Fully modernized for the latest Statamic version
- Performance Optimized: Cached minification engine for optimal performance
- Developer Friendly: Skip minification in debug mode during development
- Highly Configurable: Comprehensive configuration with environment variable support
- Error Resilient: Graceful fallback if minification fails
- Production Ready: Battle-tested with comprehensive test suite
Install the addon via Composer:
composer require el-schneider/statamic-html-minifyPublish the configuration file:
php artisan vendor:publish --provider="ElSchneider\HtmlMinify\HtmlMinifyServiceProvider"The addon provides extensive configuration options via config/html-minify.php:
return [
// Enable/disable minification entirely
'enabled' => env('HTML_MINIFY_ENABLED', true),
// Skip minification when APP_DEBUG is true
'skip_on_debug' => env('HTML_MINIFY_SKIP_ON_DEBUG', false),
// Minification options
'removeComments' => env('HTML_MINIFY_REMOVE_COMMENTS', true),
'sumUpWhitespace' => env('HTML_MINIFY_SUM_UP_WHITESPACE', true),
'removeSpacesBetweenTags' => env('HTML_MINIFY_REMOVE_SPACES_BETWEEN_TAGS', true),
// ... and many more options
];All configuration options support environment variables for easy deployment:
HTML_MINIFY_ENABLED=true
HTML_MINIFY_SKIP_ON_DEBUG=true
HTML_MINIFY_REMOVE_COMMENTS=trueFor detailed configuration options and advanced usage, see the DOCUMENTATION.md.
- PHP 8.2+
- Statamic v5.0+
- Laravel 10/11
Run the test suite:
vendor/bin/pestThis addon is maintained by el-schneider and builds upon the original work by:
- Vaggelis Yfantis - Original author and creator
- All Contributors
Big thanks to Vaggelis for creating this addon and sharing it with the community! 🙏
The MIT License (MIT). Please see License File for more information.