HTML output + PHP strip-whitespace

Soldato
Joined
12 Jun 2005
Posts
5,361
Hi there,

I hear its best (& not detrimental) to strip whitespace from the outputted html to save bandwidth.

Most of my sites work on php and includes with footers and headers, etc....

What would be the best way to go about striping whitespace? Ideally i would like something that i can comment out for debugging purposes.

Does anyone do this? How did you go about doing this?

Thanks.
 
Its not that my pages are loading too slow, its just i thought i would try this to optimize for bandwidth saving.

At the moment my pages are all perfectly tabbed and look like a piece of art when you view the source, which is a bit stupid because it's useless, other than for debugging.

Surely you would have to buffer your entire script's output in order to strip the whitespace, giving the impression of a far slower load time?

See - this is what i was afraid of, i was just wondering if anyone has actually done this and can say how it went...etc....
 
What I'd do is the following:

Continue to tab out your code on your development machine.
Run a copy of it through a script to remove the whitespace.
Upload this stripped version to the server.

This means you'll always have your nicely tabbed version ready for adjustments, without having to sift through a solid block of text! ;)

Good idea, don't get me wrong - but is there a sophisticated enough code which will strip whitespace in php pages that output html etc....
 
Back
Top Bottom