Compressing HTML output

machinedean - 2 weeks ago

Hi all, apologies if I've missed something in the documentation but I cannot see an obvious way to minify HTML output. I know there are various Laravel packages out there but given that Pyro uses twig templates I'm not sure whether these will be supported. Thanks in advanced!

ryanthompson - 2 weeks ago

Spaceless is all I've got right now but I am open to improvements. I feel like spaceless is probably the easies to incorporate though for sure (at the moment).

piterden - 2 weeks ago

If you want to optimize the size of the generated HTML content, gzip compress the output instead.

machinedean - 2 weeks ago

Thanks guys, much appreciated.

machinedean - 2 weeks ago

Thank you William! I did search on the forum but I didn't spot this one.

machinedean - 1 week ago

Hi, apologies for the slow reply. I've tried both spaceless and and neither are minifying the HTML on the page. Any ideas why this might be happening?

ryanthompson - 1 week ago

@machinedean just wrap your HTML with {% htmlcompress %} like this:

Note though - do NOT use defer on any internal blocks. It seems to not play well with the compression.

You don't need to include this yourself anymore core comes with htmlcompress now.

machinedean - 1 week ago

Thanks Ryan. That all makes sense, we'll update soon and implement.