如何使用PlayFramework压缩html [英] How to compress html with PlayFramework

查看:80
本文介绍了如何使用PlayFramework压缩html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了提高Scala表单的可读性,我经常使用缩进和换行符.但是,当我在播放应用程序启动并运行时验证HTML时,会看到很多空白和不必要的换行符.为什么要压缩这些HTML而不会使我的Scala模板不可读"?

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"?

谢谢

推荐答案

如另一个答案中所述,框架中没有任何东西可以缩小HTML.

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

为此,您将必须使用前端HTTP服务器,例如 Nginx .您应该看看条带模块.

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

您还应该问自己,这种缩小是否真的有用.压缩您的答案将减小其大小.在HTML上添加缩小标记(我从未见过)似乎是过早的优化.

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.

这篇关于如何使用PlayFramework压缩html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆