HTML minification in sbt build for Playframework
Asked Answered
B

2

8

I'm porting a project over to the playframework. Previously I was using htmlcompressor integrated in the build using this maven plugin: http://code.google.com/p/htmlcompressor/#Maven_Plugin

Is anyone aware of a comparable html minification option compatible with sbt that I could integrate into my Playframework build?

Note: I'm well aware that html minification is a last step optimization that matters little and should be applied after all other optimizations are completed, but this is a project that was already been enjoying the benefit of html minification so I'm just exploring the possibility.

Besprent answered 30/12, 2012 at 14:7 Comment(4)
And how is this question related to ivy? The library is available from Maven Central, so should be easy to integrate with sbt: search.maven.org/…Kriemhild
My understanding is that sbt uses ivy to resolve maven dependencies -- thus the tag. If it's not appropriate I can definitely remove it. Can you provide any other details on how one can integrate a maven plugin into an sbt build? I've looked around but this question seemed to indicate that it's not possible: https://mcmap.net/q/1471980/-use-maven-plugin-on-sbt.Besprent
I strongly recommend you to use play framework and nginx http server together. nginx can compress all stuff that go through network with gzip algorithm and this has a much greater impact than minification of htmls.Extant
I'm aware that gzip compression is WAY more important that HTML minification. I tried to make that clear in the question. I'm aware that this can be done with a proxy server but I don't really want to do it with a proxy server as I really feel it should be done during the build -- why waste cpu cycles on compression that can be done at build time. This site already has HTML minification and that's why I'm looking to preserve it. The question is can someone help me integrate HTML minification into my SBT build to be run on my *.scala.html files at build time. If the answer is no that is fine.Besprent
V
3

Ranked by possible helpfulness:

  1. How to compress html with PlayFramework
  2. play-minifymod found via this discussion:

    Since Play 1.2.x has no build in support for response optimization like minify and gzip responses this module adds this functionality using the YUI Compressor and googles htmlcompressor

  3. Play framework auto javascript and CSS minifier

Vanlandingham answered 1/1, 2013 at 16:3 Comment(1)
Thanks. Javascript and CSS are covered in play 2.0 just fine -- it's really just HTML minification I'm looking for. Though I love nginx I'd prefer not to have to run behind a proxy server just for html compression and I also don't want to do it on the fly as I'd prefer no compression to the computational expense of doing it for each request. What I'm really looking for is something that runs during the SBT build that takes all of my *.scala.html resources and runs htmlcompressor on them.Besprent
P
1

Play Framework 2.1 that is about to be released (we already use it in production), has built in support for gzipping html responses. See this pull request - https://github.com/playframework/Play20/pull/375

Pickup answered 5/1, 2013 at 21:27 Comment(2)
This is HTML minification I'm referencing, not gzip compression.Besprent
developers.google.com/speed/pagespeed/…Besprent

© 2022 - 2024 — McMap. All rights reserved.