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
Laravel Page Speed

Laravel Page Speed Laravel Package

dotninth/laravel-page-speed

A Laravel middleware package that speeds up your app's responses by minifying HTML output, removing comments and unnecessary whitespace, and applying other page-speed optimizations automatically.

View on GitHub
Deep Wiki
Context7

Turbo-boost page load speeds with HTML minification and optimization.

Frequently asked questions about Laravel Page Speed
How do I install dotninth/laravel-page-speed in a Laravel app?
Install it with Composer using composer require dotninth/laravel-page-speed, then register the package's middleware in your HTTP kernel or on a route group as described in the README. Laravel's package auto-discovery may handle the service provider, but verify that in your application version. Run your test suite and inspect a real response to confirm minification is active.
Which Laravel and PHP versions does laravel-page-speed support?
The repository's composer.json is the authoritative source for illuminate/* and PHP constraints, so check it before installing. Because Laravel releases a major version annually, confirm the package line you choose explicitly supports your Laravel major rather than assuming compatibility. If your app runs an older or newer Laravel version, test the integration in a staging branch first.
What does Laravel Page Speed actually do to my HTML responses?
It acts as middleware that post-processes the response body, minifying HTML by removing comments and unnecessary whitespace and applying other page-speed optimizations. This reduces transfer size and can improve time to first byte and render metrics. It does not replace asset optimization, caching, or CDN configuration, so treat it as one layer in your performance stack.
Is HTML minification middleware safe for production Laravel applications?
Generally yes, but test against real rendered pages because minification can affect inline scripts, preformatted content, and whitespace-sensitive markup if the rules are too aggressive. Run your feature and browser tests, compare responses before and after, and check pages that rely on whitespace or comments. Roll it out behind a feature flag or in staging first.
How do I configure laravel-page-speed, and can I disable specific optimizations?
Configuration is typically handled through a published config file or middleware options, but the exact keys depend on the package version, so consult the README and config source. Do not assume a toggle exists for every optimization; verify which behaviors are configurable before relying on them. If you need granular control, wrap or extend the middleware rather than editing vendor code.
Where should I register the page speed middleware in Laravel?
Register it as global middleware or on a route group where HTML responses are returned, following the package README instructions. Middleware order matters: place it after middleware that generates or modifies the response body, and before anything that expects final output. Avoid applying it to API or file-download routes where minification is irrelevant.
Can laravel-page-speed break Livewire, Inertia, or Blade components?
It can affect any HTML response, including Blade-rendered pages, so test Livewire and Inertia pages carefully because their markup and inline scripts may be sensitive to whitespace changes. Minification usually preserves rendered output, but client-side hydration and inline JSON can be fragile. Run browser tests on interactive pages before enabling it globally.
How do I test that the middleware is minifying responses correctly?
Write a feature test that hits a route returning HTML and assert that comments and excess whitespace are removed while visible content remains intact. Add regression tests for pages with inline scripts, textarea content, and pre tags. In production, compare response sizes and check for rendering errors after deployment.
Does laravel-page-speed work with cached or compressed responses?
Middleware runs on the response object before it is sent, so it can minify HTML that your application generates, but it does not manage Laravel's response cache or server-level gzip and Brotli compression. If you cache rendered HTML, confirm whether caching happens before or after middleware so minification is applied consistently. Avoid double-processing responses that are already minified.
What are alternatives to laravel-page-speed for Laravel HTML minification?
Alternatives include dedicated HTML minifier libraries called from middleware, web server or CDN minification features, and broader performance packages that combine caching and asset optimization. Choose based on whether you need Laravel-specific middleware, fine-grained control, or infrastructure-level handling. Compare maintenance activity, Laravel version support, and test coverage before switching.
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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console