Sorry for the ridiculous post title, but I just had to. What I'm talking about is the desire to keep your HTML output condensed, but not to make development difficult in the process.

For example, if you want a custom chunk of CSS on a given page, you might want to drop inline, in your <head>. But, if you're like me, you can't stand it when the page source shows dozens of lines of CSS/JS before you reach the <body>.

So, why not minify that CSS on-the-fly.

ColdFusion example

Page-specific CSS

<cfsavecontent variable="mycss">
<style type="text/css">
   h1 { font-size: 2em; }
   h2 { font-size: 1.5em; }


Main Template file

<!--- nicely minified CSS code below --->
<cfoutput>#Replace(Replace(mycss, chr(9), "", "ALL"), chr(13) & chr(10), "", "ALL")#</cfoutput></cfif>



Leave a Reply

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