Assets

Applications and libraries commonly use files that will be delivered to the client (typically web browsers) without being modified. Examples are icons, css files, javascript files etc. Enonic XP provides a standard and optimized approach to serving assets across applications.

Developers simply place the files they want to use into their project’s /src/main/resources/assets/ folder. These files can then be dynamically accessed through the asset service. The asset service is typically available through _/asset/<myapp>/path/to/myasset.ext.

The assetUrl() portal function lets you easily create links to assets.

assetUrl({path [,application] [,type] [,params]})
Arguments:
  • path (string) – Path to the asset.
  • application (string) – Application where the asset exists. Default is current application.
  • type (string) – URL type. Either server (server-relative URL) or absolute. Default is server.
  • params (object) – Custom parameters to append to the url.
Returns:

The relative or absolute URL to the asset.

API

The detailed API documentation may be found here.