New Javascript minification disabling option in eXo Platform 5.0

Thanks to its built-in Javascript module support, eXo Platform allows to easily integrate any custom or third-party Javascript. The script must be declared in the file WEB-INF/gatein-resources.xml of your extension webapp:

JavaScript

1

2

3

4

5

6

<module>

<name>myscript</name>

<script>

<path>/javascript/myscript.js</path>

</script>

</module>

and can then be injected in any other page, portlet or other script:

JavaScript

1

2

3

4

(function(myscript){

myscript.doWhateverYouWant();

...

})(myscript);

The declared javascript files are automatically minified to reduce their size and therefore the size of resources fetched in web pages. This is a good practice but it can cause issues when the script is not compatible with the minifier used in eXo Platform (Google Closure Compiler). For example, this issue has been discovered for React.js (chapter “Incompatibility with the GateIn minifier”).
In eXo Platform 5.0 we added a new option in the Javascript module configuration to disable the minification: minify. The default value is set to true to keep backward compatibility.

JavaScript

1

2

3

4

5

6

7

<module>

<name>myscript</name>

<script>

<minify>false</minify>

<path>/javascript/myscript.js</path>

</script>

</module>

When the minify option is set to false, the script is injected as is, without any alteration. It allows to package your already minified script, with the source map files, using your favorite tool (webpack, …).

We believe this will make third parties’ Javascript libraries easier to integrate and therefore improve the developers’ experience.

I am a software architect at eXo. With the developers, I (try to) convert technically what the product management people have in their minds. I also assist the support team in answering customers’ questions.
In this blog, I share what we develop in the platform and provide tips to help customers to use or customise it.