How to compress html with PlayFramework
Asked Answered
S

3

6

In order to improve the readability in the Scala forms I use indentation and new lines frequently. But when I verify the HTML when my play application is up and running I see a lot of white spaces and unnecessary line breaks. is there any why to compress this HTML out without "making my scala templates unreadable"?

Thanks

Settle answered 9/7, 2012 at 20:29 Comment(0)
S
4

As said in another answer there is nothing in the framework which permits to minify your HTML.

To do so you will have to use a front-end HTTP server like Nginx. You should have a look at strip module.

You should also ask yourself if such minification is really usefull. Gziping your answer will reduce its size. Adding minification on HTML (I have never seen that) seems premature optimization.

Sizing answered 10/7, 2012 at 9:0 Comment(0)
A
3

It does exist HTML compression and is being used: https://code.google.com/p/htmlcompressor/

For play 2.x you can use the this filter

Aniline answered 11/3, 2015 at 12:17 Comment(0)
N
1

As i read the play framework documentation it does not seem to support compressing of output html. It does support compressing of static assets (scroll down on this page).

Perhaps, if you run play behind a reverse proxy (e.g. via apache or nginx) i think you can have the proxy compress your html. (This might be worth another question.)

Nebulosity answered 9/7, 2012 at 21:13 Comment(1)
hmm, yes I already use the static compression of assets.. I think that using GZip is the only thing that I can do to make the HTML smaller in size to transfer to the client. Thanks!Settle

© 2022 - 2024 — McMap. All rights reserved.