The question is pretty self explanatory. Why shouldn’t I strip it? It seems to me that most of the whitespace is used purely for formatting in the text editor and has no impact on the final page.
What’s more, when these random nodes of whitespace do have an impact on the final page, it is usually an impact I do not want, such as a mysterious one character (after whitespace collapse) gap between inline-blocks.
I can strip all these whitespace text nodes pretty easily. Is there any reason I shouldn’t?
edit:
It’s mainly for the strange behaviour where whitespace, rather than for performance. One example is me wanting to put images side by side using inline-block instead of float, while preventing wrapping to next line and allowing them to spill out of the parent.
The whitespace causes these mysterious gaps, which can be removed by basically minifying the HTML source code to remove the whitespace between inline-blocks manually (and completely messing up your source code formatting in the process).
There’s no reason not to, really. It can be done very easily with something like htmlcompressor.
However, assuming you’re delivering all your html, css, and js files via gzip, then the amount of real-world bandwidth savings you’ll see from stripping whitespace will be very small. The question then becomes, is it worth the trouble?
UPDATE:
Perhaps this will affect your decision. I performed a simple minification on a page of my website just to see what kind of difference it would make. Here are the results:
BEFORE minification
AFTER minification
The uncompressed file is about 3 KB smaller after minification. But that’s not really what matters. The gzip compressed file is what is sent over the wire. And you can clearly see that gzip does a pretty good job even with the non-minified HTML.
I see the benefit of minifying js libraries, or things that aren’t changing constantly. But I don’t think it’s worth the trouble doing this to your HTML for a measly 130 bytes.