OpenWGA 7.6 - OpenWGA Concepts and Features

Design and development » JavaScript and CSS

JSMIN Preprocessor

The JSMIN processor acts on JS resources with extension "jsmin". It has two main features:

  • It can "combine" JS-Resources to one resource
  • It minimizes the resulting JS-Code using UglifyJS

If you have a jsmin recource in /scripts/js with name my-script.jsmin you can include it as follows:

<script src="<tml:url type="js" name="my-script"></script>

The JS-Code will be served minimized if the WGA runtime does not run in developer mode.

Other JS-Resources can be imported using the following syntax:

//@import test
//@import test@base
//@import type=file db=ig path=/lib/s.js
//@import db=plugin-wga-app-framework amd/require-config
//@import type=static js/htmlhead.js

The syntax of the path to imported resources is the same as used for scss resources.

//@import type=<type> db=<dbkey> path=/path/to/resource

"path" can be omitted. The default "type" is "js".

Together with other improvements in 7.2.2 this can be used to reduce the <script src="..."></script> in html head to one single <script> include.

Sample using require-JS:

<script data-main="main.js" src="<tml:url type="js" name="application"/>"></script>
<tml:htmlhead scripts="false"/>

application.jsmin (combines htmlhead.js, require.js and require-config.js into one single resource):

//@import type=static js/htmlhead.js
//@import db=plugin-wga-app-framework amd:require
//@import db=plugin-wga-app-framework amd:require-config