
Andy Pemberton is a Sun Certified Enterprise Architect and Lead Consultant. Andy is an open source enthusiast with a depth of experience in JavaEE and Portal environments.
Compress your JBoss Portal Theme with pack:tag
Dec 08 2008
The goal of this article is to show you how to use pack:tag to optimize the performance of your JBoss Portal theme. I’ve used this approach on a production JBoss Portal 2.6 implementation and tested the approach out in version 2.7.
JBoss Portal has a feature-rich theme framework where CSS and javascript resources are included in the Portal; building a custom theme is easy. Pack:tag is an open source project that optimizes performance for java-based web apps; it provides a JSP tag library that automatically minifies, compresses, and combines CSS and javascript resources.
As more rich features and dynamic components reach your portal, larger AJAX frameworks and CSS libraries are required to support them. Large downloads will not only make your Portal load slower, but will also take longer to execute when using the Portal. Also, Portals are no longer accessed solely inside the firewall, many companies use them to power external facing sites - so few assumptions should be made about client bandwidth. Compressing your Portal theme with pack:tag will lead to faster downloads and page response time.
Building a custom Portal theme is covered in depth elsewhere, so we won’t get into that here. Instead, let’s look at the steps necessary to get your theme working with pack:tag:
<%@ taglib prefix="pack" uri="http://packtag.sf.net" %>
<pack:style> <src>/styles/extjs/css/ext-all.css</src> <src>/styles/extjs/css/xtheme-gray.css</src> <src>/styles/app.css</src> </pack:style>
<pack:script> <src>/scripts/jquery/jquery.js</src> <src>/scripts/extjs/adapter/jquery/ext-jquery-adapter.js</src> <src>/scripts/extjs/ext-all-debug.js</src> </pack:script>
<jsp:include page="includes/theme-${requestScope['RENDERCONTEXT'].themeContext.theme.themeInfo.name}.jsp" />
Check out the following Firebug screen shots depicting the actual file size savings in our custom theme:

Custom Theme CSS Before pack:tag

Custom Theme CSS After pack:tag

Custom Theme JS Before pack:tag
Custom Theme JS After pack:tag
That’s right! Adding pack:tag resulted in: