Calendar

««Feb 2012»»
SMTWTFS
    1234
567891011
12131415161718
19202122232425
26272829

Alert Email

Get a short email alert whenever a new entry is published.

Confidential, secure it's piece of cake to keep uptodate.

Optimize your CSS with CFSTYLESHEET

Published: 10:02 AM GMT, Friday, 13 February 2009

Last week we introduced the new tag CFJAVASCRIPT to the nightly build release and many people have been playing with it. The beauty of open source is that we can release features quickly and get your feedback so we can incorporate those before they get blessed to be part of the official release. For example a subtle bug was reported against Tomcat usage, which was quickly quashed.

To complete the client side optimization we've just introduced the compliment to the CFJAVASCRIPT tag, which is the CFSTYLESHEET tag, which does for your CSS files that CFJAVASCRIPT does for your Javascript files.

Just as before, you pass in a list of relative web paths, and OpenBD will add them together, and if you opt to, you can have it remove all the verbosity usually associated with CSS files.

<html>
<head>
<cfset cssFiles = ArrayNew(1)>
<cfset ArrayAppend( cssFiles, "corestyle.css" )>
<cfset ArrayAppend( cssFiles, "additional.css" )>
<cfstylesheet src="#cssfiles#" minimize="true">
</head>
<body></body>
</html>

CFSTYLESHEET will also advise the browser to aggressively cache the files at their end to reduce the load on your server. Should any of the files change on the file system though, OpenBD will rebuild the collected file and redeliver it to the browser.

You can view the full details of CFSTYLESHEET on our wiki which details the various attributes you can pass in.

The compression isn't as dramatic as that of the CFJAVASCRIPT tag. For example, no class names or selectors are changed. Only white space and comments are removed. Which depending on how verbose your web designers are, can be quite significant.

This tag is available from today in our nightly builds, and will be rolled into our upcoming 1.0.2 release.

Comments (1)

I was thinking that it would be nice if this tag could support a comma-delimited list of stylesheets in addition to an array and a single string path especially because we cannot create implicit arrays using the shorthand notation yet in OpenBD.

left by Peter J. Farrell . Monday, 23 February 2009 7:14 AM
Add Comment