Bummer that this arrived after the others. Had I seen them first, I could have saved us all a little time and just focused on the additional detail and the couple options that not yet mentioned. Oh well. Hope it will help someone. :-)
 
...actually, I was about to say, "ok, I'll just turn it into a blog post", and then as I started it, I remembered reading a quip from Ray Camden some time ago about a country with people starving for whitespace so wanted to get it and quote it. I found the entry, from 2005 (http://ray.camdenfamily.com/index.cfm/2005/11/21/Intermediate-Contest-Entry-4):
 
    This isn't the end of the word, but will create extra whitespace. (Somewhere... out there.... a poor country is yearning, begging, pleading for whitespace. ColdFusion is there to meet that need!)
 
Sadly, I have to say, I also saw in that search a post he made just a couple weeks ago (that I had missed until now) on this very topic.
 
ColdFusion Whitespace Options
 
Indeed, just a little more searching turned up this 4-part series from Lucas Sherwood (in an entry where he was pointing to Ray's post), http://www.thebitbucket.net/weblog/index.cfm/2006/7/27/Whitespace-and-ColdFusion:
 
 
Oy. Lesson learned. It pays to do a little searching before writing (as much as before asking).
 
/charlie
http://www.carehart.org/blog/
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Charlie Arehart
Sent: Friday, August 11, 2006 4:05 PM
To: discussion@acfug.org
Subject: RE: [ACFUG Discuss] White Space In Source Code

Robert, there are many solutions, 3 specific tags, 2 tags with related output control, one admin console setting, a new feature in CFMX 7 that might be helpful, and a couple of approaches not related to CFML. Pardon the few paragraphs to explain it all, but each has difference nuances and indeed offers varying levels of suppression and has slightly varying purpose (which reflect the evolution of CFML over time).
 
First, there are 3 tags:
 
<cfprocessingdirective suppresswhitespace="Yes">
 
    ... do whatever

</cfprocessingdirective>
 
It's described as controlling "whether to suppress white space characters within the cfprocessingdirective block that are generated by CFML tags and often do not affect HTML appearance. Does not affect any white space in HTML code.". That's its intent, anyway. I think people have had varying experience, but I could be wrong.
 
Note that with that tag you MUST offer a closing tag--and it has to be in one template, can't be split with one in the application.cfm, and the closing in the onrequestend.cfm.  :-)
 
Still another tag is <CFSILENT></CFSILENT>. It's described as, "Suppresses output produced by CFML within a tag’s scope. ". Again, this is a paired tag and both must be in a single template (can't be split up).
 
An older form is:
 
<cfsetting enablecfoutputonly="Yes">
 
which doesn't require a closing tag. With it, then the ONLY output generated from the CFML page (including HTML tags and static text) will be that placed within a CFOUTPUT statement. Again, even to write out an html tag and/or static text, you'd need to wrap it (or a big block of it) in a CFOUTPUT. This often confuses people, either because they forget it's on and wonder, "where's my text"? Or they turn it on intentionally and forget to wrap static text in it and wonder, "why isn't this showing up?"
 
Note that if you want to turn it back on (or off, depending on how you look at it), you use </cfsetting enablecfoutputonly="no">. And note also that this CAN indeed be split over multiple files within a request.
 
Another source of confusion with these approaches is the question of whether they impact included files and custom tags. There are differences between them in this regard, I'm pretty sure, and may be differences in behavior regarding that between CF and BD, as well as within different versions of each. Again, this stuff has been evolving over time.
 
Still another way to control output, in CFCs (CFCOMPONENT) and CFC methods and UDFs (using CFFUNCTION) is their available OUTPUT attribute. OUTPUT="no/false" can also be used to prevent any output being generated from the method, at all (again, even static text). OUTPUT="yes/true" may not be obvious. It indicates that the body is to act like it's all inside a CFOUTPUT, so you can drop in references to variables for output and they are evaluated, again, just as if within a CFOUTPUT tag. If you specify no OUTPUT attribute at all, then things work like any normal CFML page.
 
Finally, there is also an Admin console setting to suppress whitespace, which suppresses white space globally (all apps). Since you can't too easily use CFSILENT and the CFPROCESSINGDIRECTIVE variant in the application.cfm, it's another way folks try to achieve suppression. Again, there are nuances, that are worth exploring before you enable it, and I'll note also differences between CF and BD in this regard.
 
Oh, a couple last ideas: if you want to take CFML out of the picture, and just feel that CF pages in general generate too much white space, you could also consider a Servlet Filter. They can process page output after the request and could be used to remove excessive whitespace. It's not trivial to do correctly, but there are ones out there (from the Java world). I wrote about them in a Feb 2003 CFDJ article, "Fun with Filters", at http://cfdj.sys-con.com/read/41574.htm.
 
(Actually, that reminds me that in CFMX 7, you could also do something like that (manually remove excessive whitespace) in the new application.cfc onrequestend method.)
 
And last but not least, as John talked about at the ACFUG meeting, you could also ask the web server to do gzip compression of all (or some) pages. Note that this does not REMOVE the whitespace, but it compresses the page so that during transfer from server to client the penalty of it is lessened. It's worth noting that the whitespace will still remain in the browser, and while browsers generally ignore it, it still could impact the speed with which the browser page loads (and possibly other behavior, since again the whitespace is indeed still there.)
 
Hope that helps.
 
 
/charlie
http://www.carehart.org/blog/
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Reil
Sent: Friday, August 11, 2006 3:18 PM
To: discussion@acfug.org
Subject: [ACFUG Discuss] White Space In Source Code

Is there a way to have CF output a page with no whitespace in the source code?

 

Robert P. Reil

Managing Director,

Motorcyclecarbs.com, Inc.

4292 Country Garden Walk NW

Kennesaw, Ga. 30152

Office 770-974-8851

Fax 770-974-8852

www.motorcyclecarbs.com


-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink
-------------------------------------------------------------
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink
-------------------------------------------------------------
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink
-------------------------------------------------------------

Reply via email to