<scripts> <name>foo</name> <script> <path>/path/to/foo.js</path> </script> <depends> <scripts>bar</scripts> <depends> </scripts>
Whenever possible, GateIn Modules (GMD) should be used. This is the best practice as it helps to manage dependencies, organize code, not pollute the global scope and it enables the parallel loading of resources.
However relying solely on GMD it is not always possible, for example when an existing portlet uses an inline script that accesses the global namespace to find functions or objects. For such situations, GateIn Portal offers old style scripts present in the head section of a web page. Such scripts need to be declared in gatein-resources.xml file as follows:
<scripts> <name>foo</name> <script> <path>/path/to/foo.js</path> </script> <depends> <scripts>bar</scripts> <depends> </scripts>
Note that:
A traditional script must be declared in scripts tag instead of module
Dependencies can be declared using depends but a script can only depend on other scripts, not modules. BTW, this is also the case on the module side: a module can only depend on other modules.
JavaScript declared in scripts will be rendered in the head of the HTML document. Therefore, scripts will be loaded and executed before the DOM is created and will likely have an impact on perceived page loading speed.
Note that it is also possible to use a script served from other domain (e.g. from a CDN). To achieve this, the url element needs to be used instead of the script element:
<scripts> <name>foo</name> <url>http://path.to/foo.js</url> </scripts>