www.FamGuerra.com

Back to Coldfusion

JSCompressor

Description

This Coldfusion UDF (User Defined Function) compresses JavaScript code removing line comments, block comments, spaces, tabs and line feeds.

Note - in order for this function to work, semicolons must be used at the end of each line.

You can find this UDF also in www.cflib.org

Download this UDF

Parameters

Name Description Required
JSCode The code to compress. Yes
bRem Remove block comments. Defaults to true. No
lRem Remove line comments. Defaults to true. No
Spc Remove spaces. Defaults to true. No
Ret Removes carriage returns and line breaks. Defaults to true. No

Return Values
Returns a string.

Example
<cfsavecontent variable="str">
   // line commet 0
   text0=0;
   //line comment 1
   /**
   block comment 1
   ****/
   text1=1;
   /* ****
   block comment 2
   */
   text2=2;    // line comment 2
   // line comment 3
   /**********************************
   block comment 3
   *************************************/
   text3=3;
</cfsavecontent>

RESULT:"<cfoutput>#JSCompressor(str)#</cfoutput>"

RESULT:"text0=0;text1=1;text2=2;text3=3;"

www.FamGuerra.com

Contacto: Webmaster


Visite: Diccionario de Especialidades Farmacéuticas

Visite: Calculadora Smartpoints Weight Watchers