Play framework auto javascript and CSS minifier

社会主义新天地 提交于 2019-12-06 11:41:49

The reason we do minimizing/compressing/merging for css/js/img is because we want to save the network bandwidth and accelerate application performance, lower the server's load and make the user be more happy.

When you are putting those groovy variables into your javascript code you are shifting to the other way, i.e. making the server slowing down. Because each request will get a different javascript file to be downloaded, and the user will be no longer benefit from the local cached js copies. For the same reason using greenscript or any other minimizing tool to compress it is meaningless, because each time your need to compress and merge again instead of get it directly from cache.

If there are cases that you HAVE TO put the groovy variables into some javascript code, you'd better separate them from other parts (which should reasonably be most the majority). By doing that you could still using greenscript or press to process your static js files and leave the dynamic parts stay inside your view.

Check out the press module. As long as the generated Javascript and css are in their separate own respective files you should be able to minify them automatically.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!