Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Htmlcompressor Bundle

Htmlcompressor Bundle Laravel Package

matthecat/htmlcompressor-bundle

Symfony bundle that automatically minifies HTML responses, stripping unnecessary whitespace and comments to reduce page size and speed up delivery. Simple to install and configure, it helps improve front-end performance without changing templates or application code.

View on GitHub
Deep Wiki
Context7

Symfony2 bundle which allow to minify cacheable HTML and XML responses using htmlcompressor.

Frequently asked questions about Htmlcompressor Bundle
Does matthecat/htmlcompressor-bundle work with Laravel?
No. It is a Symfony 2 bundle built around Symfony's kernel.response event and container configuration, so it has no Laravel service provider or middleware integration. Laravel developers should use a dedicated minifier such as voku/html-min or write a small response middleware. Installing it in a Laravel app adds Symfony 2 dependencies without providing usable integration.
Is matthecat/htmlcompressor-bundle still maintained?
No. The repository is an archived Symfony 2-era bundle with no maintainer and no dependents. Symfony 2 has been unsupported since November 2018, so any code path kept alive on it is unpatched by definition. Treat it as a reference implementation only rather than a production dependency.
What Symfony versions does this HTML compressor bundle support?
It targets Symfony 2.x conventions, including bundle naming, container XML or PHP config, and no autoconfiguration or autowiring. There is no drop-in path to Symfony 5, 6, or 7 without forking and rewriting the dependency injection configuration. Modern Symfony apps should use a maintained minifier or an HTTP-layer solution instead.
How do I install matthecat/htmlcompressor-bundle?
For a legacy Symfony 2 application, it is installed with Composer and enabled in AppKernel with the bundle's DI settings configured. Installation alone is not enough for a modern app because the package is archived and its Symfony 2 dependencies are EOL. For a Laravel or Symfony 5+ project, do not install it; choose voku/html-min or a custom listener or middleware instead.
What is the Laravel equivalent of this HTML minifier?
There is no direct Laravel equivalent because this bundle is Symfony-specific. In Laravel, the common approach is a response middleware that minifies HTML after the response is generated, using a maintained library such as voku/html-min. You can also handle compression at the web server or CDN layer with gzip or brotli, which usually captures most of the transfer-size win.
Does HTML minification with this bundle break pre, textarea, or inline SVG?
Whitespace-collapsing minifiers can break sensitive HTML regions such as pre, textarea, inline SVG, conditional comments, and mixed-content boundaries. Inline script and JSON-LD blocks are also frequent casualties. If you implement minification yourself, test these cases explicitly and consider a conservative minifier configuration. The archived bundle gives you little field evidence of correctness.
How does this bundle affect ETag, Content-Length, and caching?
The bundle's listener rewrites HTML and XML response bodies when it considers the response cacheable. That can produce two different byte streams for the same resource depending on cache state, which interacts badly with Content-Length, ETag, and shared caches such as Varnish or Cloudflare. Any implementation must recalculate Content-Length and regenerate or strip ETag, and you should verify that behavior explicitly.
Should I use matthecat/htmlcompressor-bundle in production?
No. The recommended assessment is do not adopt: it is archived, unmaintained, Symfony 2-only, and has zero dependents. The bundle is a thin wrapper around a niche PHP port of htmlcompressor, so you inherit little value and all of the abandonment risk. For production, use a maintained minifier, an in-house response listener you own, or edge compression.
What are good alternatives to htmlcompressor for PHP or Laravel?
The current default choice in the PHP ecosystem is voku/html-min; htmlmin/htmlmin is another option if you prefer PSR-7 middleware semantics. In Laravel, wrap the chosen minifier in a response middleware and feature-flag it. Also measure gzip or brotli at the edge first, because HTML whitespace is typically a small fraction of an uncompressed document and near-zero after transport compression.
How do I test HTML minification in a Laravel or Symfony app?
Write feature tests that assert the response body remains semantically correct after minification, especially for pages containing pre, textarea, inline SVG, script, and JSON-LD. Check that Content-Length matches the final body and that ETag behavior is intentional. Include a production-only flag and compare measured transfer sizes before and after, rather than assuming minification improves Core Web Vitals.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core