1

I have two questions about resources in JSF2:

is there any way to set that all JSF2 resources (JS, CSS) should be compressed (gziped) or at least minified. (Something a la wro4j).

And the second one: is there any way to force exclude some library? I am using in my admin system OpenFaces, but the JS dependency is included even in the user frontend pages, even thought I never use (or import namespace) there.

Thanks

malejpavouk
  • 4,297
  • 6
  • 41
  • 67

2 Answers2

2

Gzipping is more a servletcontainer configuration. Consult its documentation for details. In Tomcat for example, it's a matter of adding the compression="on" attribute to the <Connector> element in /conf/server.xml. See also Tomcat Configuration Reference - The HTTP Connector.

<Connector ... compression="on">

You can also configure compressable mime types over there.

Minification is more a build process configuration. If you're using Ant as build tool, you may find the YuiCompressorAntTask useful. We use it here and it works wonderfully.


As to OpenFaces, that's a completely different question and I also don't use it so I don't have an answer for you. I'd suggest to just ask that in a separate question. I don't see how that's related to performance improvements as gzipping and minification.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I was thinking about some wro4j approach. I do not wish to compress (minify) every response. I want to compress JSF2 javascript dependencies only, because these compressed (minified) data may be cached and used for any response in future (using these dependencies). Selecting these dependecies one-by-one in server configuration is pretty clumsy, and I think that this is more "application related" and it should be specified and resolved in app. With the openfaces issue you are probably correct, this is only related by my current performance problems with my app. – malejpavouk Jun 15 '11 at 11:21
  • As I think about it more deeply, you are correct with the mime compression, it should at least solve part of my problems. – malejpavouk Jun 15 '11 at 11:24
1

For what concerns OpenFaces I had the same problem and I solved unpacking the JAR, minifying the huge Javascripts manually and repacking the JAR. It allowed me to save about 70 Kb per request which were impacting performance on heavy load.

elbuild
  • 4,869
  • 4
  • 24
  • 31