• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

How to make whitespace suppression work

I have read the threads on white space suppression, but they do not explain
what the cfprocessingdirective tag does.

I am using the the <cfprocessingdirective> tag as follows:

<cfprocessingdirective suppresswhitespace="yes">
... all my html and CF code within the html <body> tags ...

There are no <cfinclude> tags within the cfprocessingdirective tags.

In CF admin, I have checked "Enable white space management" and I restarted CF after setting it on.

When viewing source, I can see the total white space and count the characters by pasting it into MS Word. After adding in the tags, there is not a single white space character removed from the count according to the Word character count.

What whitespace does this tags suppress and does it work independent of the CF admin setting?
  • 3
2 Solutions
Hi 451ls,
Summery of the previous link:

1) CF server produces the white space while computing/evaluating the CF tags in html, and produces white spaces instead of the coldfusion tag for browser.
As browser does ignores white spaces it will be not displayed to you but when you see the srouce those white spaces are there instead of the coldfusion code you have in the code.

This white spaces can be removed using this tag.

2) If you have manually put the white spaces then It will not remove those white spaces there. They will be there.
This will only remove other white spaces.

More info is in the link above... If I will type here will be repeating them.

Hi 451ls,
>>> What whitespace does this tags suppress and does it work independent of the CF admin setting?
No. They work together and as per your description you have done things correct and it should work. I am thinking.

Quite frankly, after over 5 years with CF I have not seen any of there white-space removal solutions work. Here are a couple pointers based on my experience regarding white space:

A) It doesn't matter, don't waste time on it

B) Sometimes it's a good thing when people try to look at the source of your page and all they see is blank ;-)

C) Instead of trying to remove whitespace, don't create it! use <cfsetting enablecfoutputonly="yes"> before sections of your code that don't have inline HTML. Don't forget to turn it off before inline HTML: <cfsetting enablecfoutputonly="no">. I have several of those statements all over my code.

D) Use NewAtlanta's BlueDragon instead, there white-space removal works

E) Write your own custom tag to do that - If that's really what you want, I'll dig an old one up and post it here, let me know. Note that this approach may add significant processing time.
In general if you don't have tons of whitespace you won't notice a difference.

The times you will notice it is when your page is significant whitespace - such as a page I saw this week that was 1.5MB in file size and that was all whitespace except for about 1K of text.

In that case it was recommended to the developer that he turn on the whitespace removal and it worked in that case to reduce the  page size.

Otherwise if you are not in an extremem case I would go with either A or C of sigmacon's solutions/suggestions.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now