3.3.1. Adding JavaScript to your site


You are looking at documentation for an older release. Not what you want? See the current release documentation.

eXo Platform comes with some very powerful JavaScript management capabilities. You can easily control how your own JavaScript files are included in your site's pages and manage their dependencies.

Most of these capabilities can be done with some declarations in the gatein-resources.xml file of your extension.

Adding JavaScript to all pages of a site

This usecase is used when you want to add JavaScript to all pages of a site named "my-site":


Adding JavaScript to a page when its portlet is displayed

This usecase is used when you want to add JavaScript to a portlet named "my-portlet".


JavaScript modules

The eXo Platform JavaScript improvements are built on top of the notion of JavaScript module. JavaScript does not provide a natural way for namespacing and the notion of module was designed to solve this problem. Namespacing can be perceived as a natural lack, however this lack should be seen as an advantage as modules provide more and more namespacing. Indeed, the module pattern allows creating and resolving dependencies between modules at runtime on demand and loading JavaScript resources in parallel.

The notion of module can be viewed as:

At runtime, the dependency system defines a graph of function to execute that makes the product of each module be injected in the other modules. It can be seen as a simple dependency injection system which can load modules in an asynchronous and parallel fashion providing parallel loading, namespacing and dependency management.


See JavaScript Development for further information about JavaScript.

When adding JavaScript to your site, you need to consider the following specific usecases:

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus