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:
<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:
(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.
<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.