Possible Duplicate:
How to minify php page html output?
Any reason not to strip whitespace in HTML
I viewed some page sources and found some difference between them - some with indents some doesn't. The first screen capture is google's page source, and the second SO's.
I want to know whether eliminating those spaces improve page loading speed or it means smaller data flow from server to client. If doing so is meaningful, how do i do it before output data from server(I use PHP).
Without spaces-Google's page source:
With spaces-SO's page source:
This is called "minification". Most of the savings are in the bandwidth of not needing to transmit all of the extra whitespace, etc. - though even this is minimal overhead if GZip compression is used (transparently supported by all major web browsers and web servers). There may also be very slight performance savings in the browser not needing to parse through the additional whitespace.
There are many libraries that can do this for you. http://code.google.com/p/minify/ is just one of them.
You're looking at minification here which uses techniques such as removal of whitespace and variable renaming to minimize the number of bytes transferred. However, the bottleneck is often not from delivering site content and you should first determine through profiling whether you really do need to optimise your page at all.
This is a tool for minifying HTML.
Trimming excess whitespace could marginally reduce down the size of a page but the savings are likely to be small.
Likely Google's page source is machine generated or compiled into something more size-efficient. It's worth noting that a few bytes of saved data in a page might be insignificant to most of us but if you're serving the page millions of times a day then you'd save yourself [millions] * [bytes saved per page]
bytes a day which could end up being significant if you're Google.
Minifying everything possible is always a good idea when using limited bandwidth, reducing the amount of data sent over HTTP
will most definitely decrease the load time!
Check this out: http://code.google.com/speed/page-speed/docs/payload.html#MinifyHTML