- java.lang.Object
-
- jakarta.faces.component.UIComponent
-
- jakarta.faces.component.UIComponentBase
-
- org.omnifaces.component.stylesheet.StylesheetFamily
-
- org.omnifaces.component.stylesheet.CriticalStylesheet
-
- All Implemented Interfaces:
PartialStateHolder
,StateHolder
,TransientStateHolder
,ComponentSystemEventListener
,FacesListener
,SystemEventListenerHolder
,EventListener
public class CriticalStylesheet extends StylesheetFamily
The
<o:criticalStylesheet>
is a component based on the standard<h:outputStylesheet>
which renders a<link rel="preload" as="style">
instead of<link rel="stylesheet">
and automatically changes therel="preload"
torel="stylesheet"
during window load event. Additionally, it will automatically be moved to the very top of the head.Usage
Just use it the same way as a
<h:outputStylesheet>
, with alibrary
andname
.<o:criticalStylesheet library="yourlibrary" name="scripts/filename.js" />
You can even explicitly configure third-party stylesheet resources to be loaded this way, such as PrimeFaces stylesheets.
<o:criticalStylesheet library="primefaces" name="components.css" /> <o:criticalStylesheet library="primefaces" name="layout.css" />
- Since:
- 4.5
- Author:
- Bauke Scholtz
- See Also:
StylesheetFamily
,CriticalStylesheetRenderer
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMPONENT_TYPE
The component type, which is "org.omnifaces.component.stylesheet.CriticalStylesheet".-
Fields inherited from class org.omnifaces.component.stylesheet.StylesheetFamily
COMPONENT_FAMILY
-
Fields inherited from class jakarta.faces.component.UIComponent
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY
-
-
Constructor Summary
Constructors Constructor Description CriticalStylesheet()
Construct a newCriticalStylesheet
component whereby the renderer type is set toCriticalStylesheetRenderer.RENDERER_TYPE
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
processEvent(ComponentSystemEvent event)
Makes sure the critical style sheet gets added to top of head.-
Methods inherited from class org.omnifaces.component.stylesheet.StylesheetFamily
getFamily, getRendersChildren
-
Methods inherited from class jakarta.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent
-
Methods inherited from class jakarta.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
-
-
-
-
Field Detail
-
COMPONENT_TYPE
public static final String COMPONENT_TYPE
The component type, which is "org.omnifaces.component.stylesheet.CriticalStylesheet".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CriticalStylesheet
public CriticalStylesheet()
Construct a newCriticalStylesheet
component whereby the renderer type is set toCriticalStylesheetRenderer.RENDERER_TYPE
.
-
-
Method Detail
-
processEvent
public void processEvent(ComponentSystemEvent event) throws AbortProcessingException
Makes sure the critical style sheet gets added to top of head.- Specified by:
processEvent
in interfaceComponentSystemEventListener
- Overrides:
processEvent
in classUIComponent
- Throws:
AbortProcessingException
-
-