fitztrev / laravel-html-minify
Minifies the HTML output of Laravel 4 applications
Installs: 202 389
Dependents: 1
Suggesters: 0
Security: 0
Stars: 415
Watchers: 23
Forks: 76
Open Issues: 12
Requires
- illuminate/view: 4.x
Requires (Dev)
- mockery/mockery: dev-master
- phpunit/php-code-coverage: >=1.2.10,<1.3.0
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2024-10-26 14:53:12 UTC
README
Read my preferred way of minifying HTML in Laravel 5/5.1+ apps here: Using Gulp to Minify Laravel Blade Templates
Laravel HTML Minify
For Laravel 4 - See here for L5+
About
This package compresses the HTML output from your Laravel 4 application, seamlessly reducing the overall response size of your pages.
Other scripts that I've seen will compress the HTML output on-the-fly for each request. Instead, this package extends the Blade compiler to save the compiled template files to disk in their compressed state, reducing the overhead for each request.
Why?
Even with gzip enabled, there is still an improvement in the response size for HTML content-type documents.
Installation
- Add
"fitztrev/laravel-html-minify": "1.*"
to composer.json. - Run
composer update
- Add
Fitztrev\LaravelHtmlMinify\LaravelHtmlMinifyServiceProvider
to the list of providers in app/config/app.php. - Important: You won't see any changes until you edit your
*.blade.php
template files. Once Laravel detects a change, it will recompile them, which is when this package will go to work. To force all views to be recompiled, just run this command:find . -name "*.blade.php" -exec touch {} \;
Config
Optionally, you can choose to customize how the minifier functions for different environments. Publish the configuration file and edit accordingly.
$ php artisan config:publish fitztrev/laravel-html-minify
Options
enabled
- boolean, default true
If you are using a javascript framework that conflicts with Blade's tags, you can change them.
blade.contentTags
- array, default{{
and}}
blade.escapedContentTags
- array, default{{{
and}}}
Skipping minification
To prevent the minification of a view file, add skipmin
somewhere in the view.
{{-- skipmin --}}
<!-- skipmin -->