netnak / minimatic
Installs: 53
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/netnak/minimatic
Requires
- statamic/cms: ^4.0 || ^5.0
- voku/html-min: ^4.4
README
Minimatic is a Statamic addon that minifies HTML responses and/or static cached pages using
voku/html-min.
🚀 Features
Minimatic wraps the powerful HtmlMin engine and exposes its configuration through a publishable config file. You can toggle the following features:
doOptimizeViaHtmlDomParser()– optimize HTML using the DOM parserdoRemoveComments()– remove HTML commentsdoSumUpWhitespace()– collapse excess whitespacedoRemoveWhitespaceAroundTags()– trim whitespace around tagsdoOptimizeAttributes()– optimize HTML attributesdoRemoveHttpPrefixFromAttributes()– striphttp:from attributesdoRemoveHttpsPrefixFromAttributes()– striphttps:from attributesdoKeepHttpAndHttpsPrefixOnExternalAttributes()– preserve prefixes for external linksdoMakeSameDomainsLinksRelative(['example.com'])– make internal links relativedoRemoveDefaultAttributes()– remove default attribute valuesdoRemoveDeprecatedAnchorName()– remove deprecated anchor name attributesdoRemoveDeprecatedScriptCharsetAttribute()– remove charset from<script>tagsdoRemoveDeprecatedTypeFromScriptTag()– remove deprecated type from<script>doRemoveDeprecatedTypeFromStylesheetLink()– removetype="text/css"from CSS linksdoRemoveDeprecatedTypeFromStyleAndLinkTag()– removetype="text/css"globallydoRemoveDefaultMediaTypeFromStyleAndLinkTag()– removemedia="all"doRemoveDefaultTypeFromButton()– removetype="submit"from buttonsdoRemoveEmptyAttributes()– strip empty attributesdoRemoveValueFromEmptyInput()– removevalue=""from empty inputsdoSortCssClassNames()– sort class names for better Gzip performancedoSortHtmlAttributes()– sort attributes for better Gzip performancedoRemoveSpacesBetweenTags()– aggressively trim inter-tag spacesdoRemoveOmittedQuotes()– omit unnecessary attribute quotesdoRemoveOmittedHtmlTags()– omit redundant HTML tags
📦 Installation
Install via Composer:
composer require netnak/minimatic
Then publish the config file (optional):
php artisan vendor:publish --tag=minimatic-config --force
⚙️ Configuration
Minimatic auto-registers its own replacer at runtime.
However, if you want to manually ensure it's added as a static caching replacer, edit config/statamic/static_caching.php:
'replacers' => [ // ... \Netnak\Minimatic\Replacers\MinimaticReplacer::class, ],
✅ Usage
Enable minification via your .env file:
MINIFY_RESPONSE=true MINIFY_STATIC=true
These values toggle options in config/minimatic.php:
'enable_response_minifier' => env('MINIFY_RESPONSE', false), 'enable_static_cache_replacer' => env('MINIFY_STATIC', false),
Exclude paths from minification with:
'ignored_paths' => ['!/*', 'api/*'],
🪪 License
MIT — see the LICENSE file for details.