public static void addResource(FacesContext context, String type, String libraryName, String resourceName) {
        boolean isRendered = context.getApplication().getResourceHandler().isResourceRendered(context, resourceName, libraryName);
        if (!isRendered) {
            addResourceToHead(context, type, libraryName, resourceName);
        }
    }
Adds a resource to the view if it hasn't been rendered yet.

@param context The FacesContext
@param type The renderer type (CSS or JS)
@param libraryName The library name containing the resource
@param resourceName The name of the resource
primefaces/src/main/java/org/primefaces/util/ResourceUtils.java