How to add asynchronous resources?

  Written by The Jahia Team
 
Developers
   Estimated reading time:
7.1.1.0

Is it possible to add ressources in a asynchronous way as the below script tag?

<script src="script.js" async></script> 

Answer

To add resources, you can choose the tag <template:addRessources>

However, this template does not implement the async attribute.

The list of attributes, for a javascript type, are the following ones:

  • resources : The list of resources they will be included in the defined order. 
  • targetTag : The target tag where the link will be inserted 
  • condition : optional HTML browser condition (ex : if > IE 6) 
  • insert : If set to true the resource is inserted at the top of the resources list. Otherwise, it is appended to the end. 
  • title : An optional title value for this asset (in case of a link). 
  • key : key for managing uniqueness of inline type. 
  • var : Name of the exported pageContext variable to hold the value specified in the action.