el-schneider/statamic-html-minify

There is no license information available for the latest version (v2.0.0) of this package.

An addon to minify HTML for Statamic v5

v2.0.0 2025-06-18 22:14 UTC

This package is auto-updated.

Last update: 2025-06-18 22:26:41 UTC


README

Statamic v5 PHP Test Suite

A modern HTML minification addon for Statamic v5 that automatically compresses your website's HTML output, reducing page load times and bandwidth usage.

Features

  • 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

Installation

Install the addon via Composer:

composer require el-schneider/statamic-html-minify

Publish the configuration file:

php artisan vendor:publish --provider="ElSchneider\HtmlMinify\HtmlMinifyServiceProvider"

Configuration

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
];

Environment Variables

All configuration options support environment variables for easy deployment:

HTML_MINIFY_ENABLED=true
HTML_MINIFY_SKIP_ON_DEBUG=true
HTML_MINIFY_REMOVE_COMMENTS=true

Documentation

For detailed configuration options and advanced usage, see the DOCUMENTATION.md.

Requirements

  • PHP 8.2+
  • Statamic v5.0+
  • Laravel 10/11

Testing

Run the test suite:

vendor/bin/pest

Credits

This addon is maintained by el-schneider and builds upon the original work by:

Big thanks to Vaggelis for creating this addon and sharing it with the community! 🙏

License

The MIT License (MIT). Please see License File for more information.

Resources