#Best practices for minifying HTML in Laravel

7 messages · Page 1 of 1 (latest)

nocturne tree
#

Hi folks!

New to Laravel here, so please be kind.,
I was wondering what is the recommended way to minify HTML output on the fly. I found two projects on Github, but wasn't sure which one to go with?

Please help out.

GitHub

A simple HTML minifier for Laravel 5, 6, 7, 8 & 9. - HTMLMin/Laravel-HTMLMin

GitHub

Minify your blade views, html, css and obfuscate js files on the fly. Lightweight minifier for your Laravel project. - fahlisaputra/laravel-minify

indigo mauve
#

@nocturne tree Hi.
If you primarily need to minify HTML and prefer a simple, well-supported solution, use HTMLMin/Laravel-HTMLMin.

If you need to minify not only HTML but also inline CSS and JavaScript and want more control over the minification process, choose fahlisaputra/laravel-minify.

I wish you success in your business.

ruby nebula
#

May I ask why you want to minify HTML? It's not very minifyable in the same way as JS is, and it already compresses really well.

indigo mauve
#

@ruby nebula
HTML minification provides file size reduction, faster loading speed and performance for your project.
This is a benefit that is still provided even though it cannot be minified in the same way as JS.

jade wolf
#

Why not let this be taken care off by your webserver, like nginx? As Martin says, there's not a whole lot that can be minified, apart from stripping out newlines and spaces. So something like gzip would achieve pretty much the same or even better results

ruby nebula
#

I don't think it does improve performance. I think compression already does that. How much can you really minify HTML, other than remove whitespace?

#

HTML responses are also often dynamic, which means you have to minify for each-request, much more expensive than minification at build-time as for JS