To use the
OmniFaces
CombinedResourceHandler
to optimize your website to only have 1 CSS and 1 JS file sent to the browser requires overriding some core PF code. However PrimeFaces hard codes
some resources in the HeadRenderer which leave it outside the scope of being combined like the theme.css, beanvalidation.js etc etc.
BalusC has an excellent tutorial on how to make this work found here.
PrimeFaces Extensions now includes these classes so you don't have to write your own or keep it up to date with every PrimeFaces release.
faces-config.xml
<application>
<system-event-listener>
<system-event-listener-class>org.primefaces.extensions.application.PrimeFacesScriptProcessor</system-event-listener-class>
<system-event-class>javax.faces.event.PostAddToViewEvent</system-event-class>
<source-class>javax.faces.component.UIViewRoot</source-class>
</system-event-listener>
</application>
<lifecycle>
<phase-listener>org.primefaces.extensions.application.PrimeFacesResourceProcessor</phase-listener>
</lifecycle>
Disable PrimeFaces HeadRenderer (Mojarra)
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>javax.faces.Head</renderer-type>
<renderer-class>com.sun.faces.renderkit.html_basic.HeadRenderer</renderer-class>
</renderer>
</render-kit>
Disable PrimeFaces HeadRenderer (MyFaces)
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>javax.faces.Head</renderer-type>
<renderer-class>org.apache.myfaces.renderkit.html.HtmlHeadRenderer</renderer-class>
</renderer>
</render-kit>