How to compress html with PlayFramework
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
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.
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
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 (eg via apache or nginx) i think you can have the proxy compress your html. (This might be worth another question.)
链接地址: http://www.djcxy.com/p/95136.html