What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 128 Stack Exchange communities.

Using Opera I have observed that there is a lot of trailing space in the HTML source for the main page of Stack Overflow, http://stackoverflow.com/. Is there a reason for this?

Some opening div tags have 11 trailing spaces. There are also lines that only contain space, e.g. near the end of the HTML file. The section near "Recent Badges" looks like it has been edited with an editor with automatic indention.

To verify this and to prevent any manipulation by applications I have also used Wget to retrieve the HTML and used Universal Viewer to view it (all on Windows XP). It gave the same result.

share|improve this question
1  
You fear for your bandwidth? –  Ladybug Killer Aug 19 '09 at 9:30
3  
No, but Jeff was talking about optimising Stack Overflow on yesterday's Hanselminutes. –  Peter Mortensen Aug 19 '09 at 9:34
    
Correction: not yesterday's Hanselminutes, official date is 2009-08-14. –  Peter Mortensen Aug 19 '09 at 9:39
1  
    
That is Hanselminutes episode 175 (direct download URL), Optimizing Your Website with Jeff Atwood and Stack Overflow. –  Peter Mortensen May 30 at 12:48

2 Answers 2

Although I am a big fan of minifying JS and CSS, I'm not so hot on minifying output HTML. Some reasons:

  1. HTML is dynamic, so you're paying that minify cost on every pageview; JS and CSS are cached and usually single-load, so the benefit vs. cost is much higher.

  2. It's nice to be able to view source on HTML and see something readable. (I use HTML view source far, far more often than view source on JS or CSS)

  3. The basic removal of whitespace, etc, overlaps heavily with what gzip does. So after gzip, the total reduction of whitespace removal is only 10% overall -- if that.

                             Raw       Gzipped
                     -----------    ----------
default CSS          2,299 bytes     671 bytes
de-whitespaced CSS   1,758 bytes     615 bytes 

http://www.codinghorror.com/blog/archives/000807.html

And that doesn't seem worth the cost of #1 and #2 , to me..

share|improve this answer
6  
At 2: note that I am not talking about leading white space. It is about unnecessary trailing white space. The trailing space seems to be there as a result of a simple mistake. There should be no runtime cost, just remove the static space. The HTML will read just as beatiful as before. –  Peter Mortensen Aug 19 '09 at 12:51
    
I have now annotated the screenshot to make it more clear that it is about trailing space: pil.sdu.dk/1/until2009-12-31/SOtrailingSpace%5F2009-08-19.png –  Peter Mortensen Aug 19 '09 at 13:00
    
ok, but all that space is going to get gzipped away into nothingness anyway. –  Jeff Atwood Aug 19 '09 at 13:27
    
OK, I take it as "status-declined". –  Peter Mortensen Aug 19 '09 at 13:39
    
well, it's a reasonable suggestion, but it does seem a bit like mowing the lawn with fingernail clippers. Maybe if there was some macro that did it automatically or something..? –  Jeff Atwood Aug 19 '09 at 13:53
1  
I don't know how it is implemented, but if the text is defined in some template file(s) then any advanced text editor has a function to remove all trailing white space from an entire file. I know that UltraEdit and Notepad++ have such a function. I am constantly using UltraEdit's menu Format/Trim Trailing Spaces (through a keyboard shortcut). Removing trailing spaces could also be part of the deployment system - say with a Perl script. –  Peter Mortensen Aug 19 '09 at 14:32

Given the fact that Jeff has spoken about minifying JavaScript files for bandwidth reasons in one of the recent podcasts, I think you have a valid point here. Of course the main page may not be requested as often as the JavaScript files, but it is probably the page with the most hits per day, so it's definitely worth looking into the bandwidth they could save here.

(And it's even worse than it could be, because they are using spaces for indention instead of tabs!!! I wonder who is responsible for that...)

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .