CssCompactFormat(sInput)
Last updated November 19, 2002
Version: 1 | Requires: ColdFusion 5 | Library: StrLib
Description:
This function is useful to reduce download time on large CSS style sheets, all unnecessary spaces are removed, pages will load faster. And your lovely CSS wont be ripped off as easily.
Return Values:
Returns a string.
Example:
<cfsavecontent variable="css">
.TextBig {
font-size : 12pt;
font-weight : normal;
font-family : arial;
}
.TextSmall {
font-size : 9pt;
font-weight : normal;
font-family : arial;
}
.TextTiny, SMALL {
font-weight : normal;
font-size : 8pt;
font-family : helvetica;
}
</cfsavecontent>
<b>Before:</b><br>
<style type="text/css">
#HtmlCodeFormat(css)#
</style>
<p>
<b>After:</b><br>
<style type="text/css">
#cssCompactFormat(css)#
</style>
</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| sInput | CSS you want to compress. | Yes |
Full UDF Source:
<cfscript>
/**
* Replaces all unnecessary characters from a section of CSS code.
*
* @param sInput CSS you want to compress. (Required)
* @return Returns a string.
* @author Jordan Clark (JordanClark@Telus.net)
* @version 1, November 19, 2002
*/
function CssCompactFormat(sInput) {
sInput = reReplace( sInput, "[[:space:]]{2,}", " ", "all" );
sInput = reReplace( sInput, "/\*[^\*]+\*/", " ", "all" );
sInput = reReplace( sInput, "[ ]*([:{};,])[ ]*", "\1", "all" );
return sInput;
}
</cfscript>
Search CFLib.org
Latest Additions
Shawn Porter added
DeMoronize
3 hour(s) ago
Chris Carey added
readPropertiesFi...
1 day(s) ago
Randy Johnson added
lastDayofWeek
3 day(s) ago
Frank Marion added
sitemapPing
7 day(s) ago
Top Rated
QuickSort
Rated 5.0, 3 time(s)
indentXml
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)