Is anyone aware of a method to dynamically combine/minify all the h:outputStylesheet resources and then combine/minify all h:outputScript resources in the render phase? The comi
I have an other solution for JSF 2. Might also rok with JSF 1, but i do not know JSF 1 so i can not say. The Idea works mainly with components from h:head and works also for stylesheets. The result is always one JavaScript (or Stylesheet) file for a page! It is hard for me to describe but i try.
I overload the standard JSF ScriptRenderer (or StylesheetRenderer) and configure the renderer for the h:outputScript component in the faces-config.xml. The new Renderer will now not write anymore the script-Tag but it will collect all resources in a list. So first resource to be rendered will be first item in the list, the next follows and so on. After last h:outputScript component ist rendered, you have to render 1 script-Tag for the JavaScript file on this page. I make this by overloading the h:head renderer.
Now comes the idea: I register an filter! The filter will look for this 1 script-Tag request. When this request comes, i will get the list of resources for this page. Now i can fill the response from the list of resources. The order will be correct, because the JSF rendering put the resources in correct order into the list. After response is filled, the list should be cleared. Also you can do more optimizations because you have the code in the filter....
I have code that works superb. My code also can handle browser caching and dynamic script rendering. If anybody is interested i can share the code.