public class DeferredScript extends ScriptFamily
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".
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.
DeferredScriptRenderer| Modifier and Type | Field and Description |
|---|---|
static String |
COMPONENT_TYPE
The standard component type.
|
COMPONENT_FAMILYBEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY| Constructor and Description |
|---|
DeferredScript()
Construct a new
DeferredScript component whereby the renderer type is set to
DeferredScriptRenderer.RENDERER_TYPE. |
| Modifier and Type | Method and Description |
|---|---|
void |
processEvent(ComponentSystemEvent event)
Move this component to body using
ScriptFamily.moveToBody(ComponentSystemEvent, ScriptFamily). |
getFamily, getRendersChildren, moveToBodyaddClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBindingencodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, pushComponentToEL, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent, visitTreepublic static final String COMPONENT_TYPE
public DeferredScript()
DeferredScript component whereby the renderer type is set to
DeferredScriptRenderer.RENDERER_TYPE.public void processEvent(ComponentSystemEvent event) throws AbortProcessingException
ScriptFamily.moveToBody(ComponentSystemEvent, ScriptFamily). If successfully moved,
then set the script resource as rendered, so that JSF won't auto-include it.processEvent in interface ComponentSystemEventListenerprocessEvent in class UIComponentAbortProcessingExceptionCopyright © 2012–2016 OmniFaces. All rights reserved.