tags:

views:

9

answers:

0

We are using JAWR to bundle CSS and Javascript. It has tremendously decreased the number of hits and bytes downloaded. However, we recently ran into a problem that caused css files that were not "under its control" to return a "not found" (404) code. We have a solution, but I'm wondering if there's a better one.

We defined a CSS bundle for the standard set of css files, and use to load it. We've also got a few non-standard css files, including a pair that define a "legacy" layout. They are loaded with . Finally, the JAWR servlet serving CSS was bound to the url-pattern "*.css" in web.xml. With this configuration, any request for a css file from a tag returned a 404 code. We were unable to find a combination of JAWR property settings that would fix the problem.

The solution we came up with was to modify the JAWR servlet configuration in web.xml, adding the "mapping" parameter:

    <servlet>
    <servlet-name>CssServlet</servlet-name>
    <servlet-class>net.jawr.web.servlet.JawrServlet</servlet-class>
    <init-param>
        <param-name>configLocation</param-name>
        <param-value>/jawr.properties</param-value>
    </init-param>
    <init-param>
        <param-name>type</param-name>
        <param-value>css</param-value>
    </init-param>
    <init-param>
        <param-name>mapping</param-name>
        <param-value>/jawrcss/</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
</servlet>

We changed the url-pattern for the CssServlet to "/jawrcss/*". With this change, css files loaded from the unmodified tags are not touched by JAWR. We lose JAWR's compression abilities for these files, though.

My guess is that in order to have JAWR properly process these files, we need to change the tags to tags, at which point JAWR's "orphan" processing will do the right thing. This is problematic for (at least) a couple of reasons. (1) We're using a shared code base and "cannot" modify some of the files because the others sharing those files aren't using JAWR. (2) Some files load css dynamically using JavaScript, and I don't see how to combine that with the JAWR support.

So, what is/are my question/s?

  1. Is there a way to have JAWR handle (compress, at least) CSS files loaded from tags? (The main question.)
  2. Is there a way to use JAWR with Javascript-loaded CSS?