The <o:deferredScript> is a component based on the standard <h:outputScript>
which defers the loading of the given script resource to the window load event. In other words, the given script
resource is only loaded when the window is really finished with loading. So, the enduser can start working with the
webpage without waiting for the additional scripts to be loaded. Usually, it are those kind of scripts which are just
for progressive enhancement and thus not essential for the functioning of the webpage.
This will give bonus points with among others the Google PageSpeed tool, on the contrary to placing the script at
bottom of body, or using defer="true" or even async="true".
Since 2.4 this will render the crossorigin attribute with a value of anonymous.
Since 3.13 this will also render the integrity attribute with a base64 encoded sha384 hash as SRI, see
also MDN.
Just use it the same way as a <h:outputScript>, with a library and name.
<o:deferredScript library="yourlibrary" name="scripts/filename.js" />
You can use the optional onbegin, onsuccess and onerror attributes
to declare JavaScript code which needs to be executed respectively right before the script is loaded,
right after the script is successfully loaded, and/or when the script loading failed.
| Info | Value |
|---|---|
| Component Type | org.omnifaces.component.script.DeferredScript |
| Handler Class | None |
| Renderer Type | None |
| Description | None |
| Name | Required | Type | Description |
|---|---|---|---|
binding | false | jakarta.el.ValueExpression
(must evaluate to jakarta.faces.component.UIComponent)
| The ValueExpression linking this component to a property in a backing bean. |
group | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The group name on which the deferred script resources should be combined by CombinedResourceHandler. All deferred scripts resources having the same combined group name will be combined into a single deferred script in the place where the first member of the group occurs in the component tree. |
id | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The component identifier for this component. This value must be unique within the closest parent component that is a naming container. |
library | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The "library name" part of the resource identifier. |
name | true | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The "resource name" part of the resource identifier. |
onbegin | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The JavaScript code to execute right before the script loading begins. |
onerror | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The JavaScript code to execute when the script loading has failed. |
onsuccess | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The JavaScript code to execute when the script loading is successfully completed. |
rendered | false | jakarta.el.ValueExpression
(must evaluate to boolean)
| Flag indicating whether or not this component should be rendered (during Render Response Phase), or processed on any subsequent form submit. The default value for this property is true. |
Output generated by Vdldoc View Declaration Language Documentation Generator.