Resource Coalescing in ICEfaces 3.3

Resource Coalescing in ICEfaces 3.3

ICEfaces 3.3 introduces a new framework feature called Resource Coalescing. When Resource Coalescing is enabled, ICEfaces will analyze the JSF JavaScript and CSS resources declared on the initial page load and coalesce them into a single resource of each type (.js, .css).


Why Coalesce Resources?

The key benefit of coalescing these resources is to reduce the number of requests made by the browser to the server to load the individual resource files. By reducing the number of resource requests overall page load times can be reduced, perhaps dramatically. This improvement is especially significant in situations where network latency is relatively high such as when making requests across mobile data networks, although notable improvements may even be seen when running with a local Tomcat instance.


How it Works

In response to an initial page load request (HTTP GET), the ICEfaces framework analyzes the resources to be included in the HEAD region of the page, and dynamically generates a single resource stream of each type (CSS, JavaScript) that includes all the specified resource in the head. The actual HEAD region of the HTML page served in the response is modified to include the new coalesced resources instead of the original resources, thus reducing the number of resource-loading requests the browser will make.

Note that the ordering of the resources matches the order that the resources would have appeared in the HEAD if resource coalescing was not enabled, including respecting the relative ordering of resources as specified by any Resource Dependencies.

Any request after the initial page load that changes the type and number of resources declared in the HEAD region will result in the added/changed resources being requested and loaded individually (not coalesced). This behaviour avoids the continuous regeneration and loading of the coalesced resource files each time the set of required resources changes. This is desirable as the coalesced resources can be quite large in size and it is more performant to request and transmit a few small resource files than to re-transmit a much larger coalesced resource file (mostly redundantly) with each request.


Configuring Resource Coalescing

Setting the org.icefaces.coalesceResources configuration parameter to true in the application web.xml file indicates to the ICEfaces core framework that the resources are to be coalesced (the default value is false).


Including Application Resources

The Resource Coalescing feature works with all CSS and JavaScript resources that are specified via the standard JSF2 resource loading mechanisms. For example:

  • “h:outputResource” tag
  • “h:outputScript” tag
  • @ResourceDependency annotation

( Note that using an html “<link>” tag will not work, as the link tag is not a supported JSF2 resource loading mechanism. )

Thus, including application resources in the coalescing operation is as simple as enabling coalescing and ensuring that the resources are loaded via a support JSF2 resource loading mechanism.


Tuning Resource Coalescing with Mandatory Resource Configuration

Resource Coalescing will include component resources for any components specified via the ICEfaces Mandatory Resource Configuration mechanism. This means that mandatoryResource Configuration can be used to tune the contents of the coalesced resource files to include additional components that may not appear initially on the page, but could be added later as a result of a dynamic page update. In this way additional resource requests can be avoided for components added to the page dynamically.



Resource Coalescing is very beneficial feature for projects that depend on a large set of CSS or JavaScript resources. For example, the ICEfaces Showcase sample application in its current form utilizes all the resources required by the ICEfaces framework, the Compat / ICE components, and the ACE components, as well as various application level resources. Enabling resource coalescing reduces the number of the resource requests to load the initial ICEfaces Showcase page from 26 to 15, a 42% reduction!


Leave a Reply

Your email address will not be published. Required fields are marked *

four × 4 =