Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
{float:right|background=#eee} 
{contentbylabel:title=Related Articles|showLabels=false|showSpace=false|space=@self|labels=assets,response}
{float}

...

By default, Tapestry secures file extensions ".class', ".tml" and ".properties". The list can be extended by contributing to the ResourceDigestGenerator service contribution.

How can we minimize an Asset ?

Since version 5.3, Tapestry provides a service, ResourceMinimizer, which will help to minimize all your static resources : stylesheets, JavaScript files ...

By default, this service does nothing. You should include a third-party libraries, for example the tapestry-yuicompressor project, which makes it possible to minimize CSS and JavaScript files. 

Code Block
langxml
titlepom.xml
<dependency>
    <groupId>org.apache.tapestry</groupId>
    <artifactId>tapestry-yuicompressor</artifactId>
    <version>5.3.1</version>
</dependency>

By adding this dependency, all your JavaScript and CSS files will be minimized, when you are in PRODUCTION_MODE=true. You can force the minimization of these files, by changing the value of the constant SymbolConstants.MINIFICATION_ENABLED

Code Block
titleAppModule.java
@Contribute(SymbolProvider.class)
@ApplicationDefaults
public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
{
    configuration.add(SymbolConstants.MINIFICATION_ENABLED, "true");
}

If you want to add your own minimizer, you can contribute to the ResourceMinimizer service. The service configuration maps the MIME-TYPE of your resource to an implementation of the ResourceMinimizer interface.

Code Block
titleAppModule.java
@Contribute(ResourceMinimizer.class)
@Primary
public static void contributeMinimizers(MappedConfiguration<String, ResourceMinimizer> configuration)
{
    configuration.addInstance(" text/coffeescript", CoffeeScriptMinimizer.class);
}

...

Footnotes Display