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
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 the rel="preload" to rel="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 a library and name.
<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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe component type, which is "org.omnifaces.component.stylesheet.CriticalStylesheet".Fields inherited from class org.omnifaces.component.stylesheet.StylesheetFamily
COMPONENT_FAMILYFields inherited from class jakarta.faces.component.UIComponent
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, FACETS_KEY, VIEW_LOCATION_KEY -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a newCriticalStylesheetcomponent whereby the renderer type is set toCriticalStylesheetRenderer.RENDERER_TYPE. -
Method Summary
Modifier and TypeMethodDescriptionReturns the "library name" part of the resource identifier.getMedia()Returns the media that the stylesheet applies to.getName()Returns the "resource name" part of the resource identifier.voidprocessEvent(ComponentSystemEvent event) Makes sure the critical style sheet gets added to top of head.voidsetLibrary(String library) Sets the "library name" part of the resource identifier.voidSets the media that the stylesheet applies to.voidSets the "resource name" part of the resource identifier.Methods inherited from class org.omnifaces.component.stylesheet.StylesheetFamily
getFamily, getRendersChildrenMethods inherited from class jakarta.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeAll, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getPassThroughAttributes, getRenderer, getRendererType, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, visitTreeMethods inherited from class jakarta.faces.component.UIComponent
getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent
-
Field Details
-
COMPONENT_TYPE
The component type, which is "org.omnifaces.component.stylesheet.CriticalStylesheet".- See Also:
-
-
Constructor Details
-
CriticalStylesheet
public CriticalStylesheet()Construct a newCriticalStylesheetcomponent whereby the renderer type is set toCriticalStylesheetRenderer.RENDERER_TYPE.
-
-
Method Details
-
processEvent
Makes sure the critical style sheet gets added to top of head.- Specified by:
processEventin interfaceComponentSystemEventListener- Overrides:
processEventin classUIComponent- Throws:
AbortProcessingException
-
getLibrary
Returns the "library name" part of the resource identifier.- Returns:
- The library name.
-
setLibrary
Sets the "library name" part of the resource identifier.- Parameters:
library- The library name.
-
getName
Returns the "resource name" part of the resource identifier.- Returns:
- The resource name.
-
setName
Sets the "resource name" part of the resource identifier.- Parameters:
name- The resource name.
-
getMedia
Returns the media that the stylesheet applies to.- Returns:
- The media type.
-
setMedia
Sets the media that the stylesheet applies to.- Parameters:
media- The media type.
-