Controlling Whitespace in ColdFusion
Knowledge Base
Posted by Joel
Since Coldfusion is a tag based language, every carriage return you enter between tags will show up in the final source code.
This can potentially increase the download size of your HTML depending on how much coldfusion code you have. There's a few ways around this ...
- <cfsilent> tag
This tag simply doesn't output anything. Even if you use cfoutput. Use this tag around any code at the top of the document or in your application.cfm
- <cfscript> tag
By putting all your code in cfscript tags (and thus using the javascript-like syntax), you eliminate the erroneous carriage returns.
- <cfsetting enablecfoutputonly="yes">
This one you have to be a bit more selective with as it will suppress all output except what is generated by <cfoutput> tags or cfscript's writeOutput() function.
- <CFPROCESSINGDIRECTIVE SUPPRESSWHITESPACE="yes">
Used much like cfsilent, but only removes whitespace ... cfoutput content is still output.