Aller directement à la fin des métadonnées
Aller au début des métadonnées

Recherche en cours Documentation JS-Optimizer 2.2



Main functionalities configuration of JSO is based on the jso.xml file. This file will describe, in a xml format, the list of css and js files used by an application. This files could be divided into groups.

Those groups will be used by JSO to generate a list of HTML links to js or css files, or to generate an unique, minimzed js file and/or css files.

jso.xml file localisation in a JEE application

JS-Optimizer looks for all jso.xml file in the root of all classpaths. The jso.xml file could be in the JEE application resources folder or into a jar.

If several jso.xml files are found, they will be concatenated. The order depends of class loader policies of the JEE Application Server.

jso.xml's DOCTYPE:

1 - XML description :

  • the xml entity jso is the root entity defining a jso configuration
  • the xml entity default define a propertie for all groups
  • the xml entity group define a JSO group
  • the xml entity group-ref define an inclusion relation between two groups
  • the xml entity js define a javascript file
  • the xml entity css define a css file

2 - XML Tree

  • jso
    • default * since v2.2
    • group *
      • group-ref *
      • js *
      • css *

jso.xml's elements definitions

1 - Element default Definition

This default element will define the attribut key witch can be location or timeStampPolicy or conflictRule for all groups defined in jso.xml files.
It's possible to define several defaults elements, one for each possible value of the key attribute.

Attribute key

The key attribute define the attribute to set for all groups.
This attribute is mandatory.

Attribute value

The value depend on the key attribute choosen.
If the key choosen is location then the VALUE is an url.
If the key choosen is timeStampPolicy then the VALUE is all or no or local.
If the key choosen is conflictRule then the VALUE is override or append.
This attribute is mandatory.

2 - Element group Definition

Static resources (css & js files) managed by JSO are declared into groups of resources.
This groups could be composed of other groups (see group_ref) which could be too recursively composed of other sub-groups.

  • Group entity should be defined in a jso entity.
  • Group entity contains following entity : group_ref, js, css

Attribute name

The name attribute of a group is its ID. This attribute is mandatory.
It's possible to define several groups with a same name.

Attribute location

Attribute location define the URL localisation of the resources of a group. This attribute is optional.
This attribute allows usage of tier web server providing static resources (TODO : Link to a chapter of JSO - Starting Guide).

  • If a group location is omitted then the location of the parent group will be used (notion of parent group will be described later).
  • If no location is defined, the resource should be in WebContent folder or in class path.

Attribute minimize

When js files of group are regrouped into an unique with two different modes :

  • files are merged (minimize=false) : the js files are simply concatenated into the unique file. No compression.
  • files are minimized (default) : the js files are compressed and concatenated into the unique file. The compression consists into deleting comments, useless spaces, tabs and carriage returns.

Attribute minimizeCss


Attribute retention

Define if the resource file will be written in WebContent application folder at the first call.
On further call, the resource file will be called directly. This attribute is optional and default value is false.
It affects :

  • resource files present only in a jar file.
  • js files which have to be merged and or minimized.
  • This attribute is used when J2EE application serves static resources.
  • This attribute is used only by the first group called when generating the resources links or a minimized file. This attribute is ignored for all group included in another group.

Attribute timeStampPolicy

since v2.2+

timeStampPolicy determines if {{timestamp} URL parameter will be added to the URL of a js or css resources
when links are generated in a JSP.

  • no : No timestamps information will be added to the url of a css or js link.
  • local : Timestamps information will be added to the url of a css or js link only if the resource is in the classpath or in WebContent foolder of the JEE aplication (default).
  • all : Timestamps information will always be added to the url of a css or js link.

This functionality will be described in JSO - Advanced Usage.

Attribute conflictRule

since v2.2+

conflictRule Defines the behaviour when a groups with same name are defined in several jso.xml file.
There is two mode : The last group loaded overide the revious ones or JSO merges their configuration.

  • override : the group override the previous one
  • append : the resource of the group is appended to the previous one.

This functionality will be described in JSO - Advanced Usage.

3 - Element group-ref Definition

The element group-ref is used to include a group into an other. The containt of the element is the name of the group to be included in.

Example of 'group-ref' declaration

The group group2 is included into group1.

(plus) A group could be included in several different groups.
(avertissement) group-ref should reference a group already defined.
(moins) Cyclic references are forbidden

4 - Element js Definition

This element specifies a relative path to a js resource file. Path must be relative to the location group attribute.

  • If location is not specified the resource path will be relative to WebContent Directory or class path root.
  • If location is specified the resource path will be relative to the location.
Example of 'js' element declaraation

For group2, the js file js-file-2.js is located into directory WebContent/resources/js or in package resources.js.

For group1 (which include group2) the files js-file-1.js and js-file-2.js are located on the web site

5 - Element css Definition

Same as js element, but it specifies a relative path to a css resource file.
(avertissement) Actual versions of JSO doesn't minimize css files.

Example of jso.xml file

Consider following groups :

The XML configuration of JSO of those groups is following :

Example of jso.xml file declaring resources
  • Aucun