-
Notifications
You must be signed in to change notification settings - Fork 298
Htmlcompressor
WicketStuff Htmlcompressor is an integration library for wicket and htmlcompressor. It can be used to minify (compress) the html markup. Minifying the html markup (together with gzip) can improve speed rendering, server troughput and lower bandwith usage.
Add this to your pom.xml:
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicketstuff-htmlcompressor</artifactId>
<version>[some-version]</version>
</dependency>
Register a HtmlCompressingMarkupFactory
in wicket:
public class HtmlCompressorApp extends WebApplication
{
@Override
protected void init()
{
super.init();
if (usesDeploymentConfig())
{
getMarkupSettings().setMarkupFactory(new HtmlCompressingMarkupFactory());
// if we want custom settings for our compressor we could do this instead:
// HtmlCompressor compressor = new HtmlCompressor();
// compressor.setPreserveLineBreaks(true);
// getMarkupSettings().setMarkupFactory(new HtmlCompressingMarkupFactory(compressor));
}
}
@Override
public Class<? extends Page> getHomePage()
{
return HomePage.class;
}
}
And done. Now in deployment mode the html markup will be minified.
Htmlcompressor can be customized with a lot of different options. If enabled it can minify javascript and css blocks inlined in the html too. For more info see the htmlcompressor documentation.
Wicketstuff-htmlcompressor depends only on wicket 1.5-RC7<= and htmlcompressor 1.4.
For more info see the javadoc of the classes. For a complete example see the wicketstuff-htmlcompressor-examples web application.