Do you care about indentation?
Posted 02 May 2012 - 11:22 AM
I could hardly understand why so many people could post their code with badly broken indentation in the forum.
But at the same time, it has been very long since I gave up the useless effort to output the final HTML with "correct" indentation.
So I'd like to know what you think about indentation.
Posted 02 May 2012 - 05:11 PM
Why is it difficult for you? Of course, sometimes it doesn't work as expected, but I've finally set my IDE to spaces and automatically convert any tab in my sources and switch it to 4 spaces.
I use Komodo Edit (the free version) for Mac OS X and it works fine. Of course, in some older projects, it was very far from my goals...
Posted 03 May 2012 - 12:23 AM
Yes, we can write views, partial views or widgets so that they will produce a piece of HTML output that has a clean indentation. Some tools have clever functions to help us do it.
But once you have implanted a partial view or a widget in a view, and put the content view into the layout view, it's impossible to maintain a clean indentation in the HTML output as a whole.
I once had a chance to read a code trying to produce a well indented HTML output as a whole.
In it, the HTML fragment codes had lengthy leading spaces so that they could fit well into the main code. And some utility subroutines had a parameter named 'indent_depth' in order to change the leading spaces. And what you've got after all is a set of source codes that are very hard to read and maintain.
Posted 03 May 2012 - 07:13 AM
Posted 03 May 2012 - 08:51 AM
Because I want to be able to compress the output to the browser.
Human readability is not really a concern to me, performance is.
However, when debugging, readable page source is a godsend.
So I want to toggle it.
Posted 03 May 2012 - 10:52 AM
To developers, just give a good source code
Also, totally agree with JacMoe and Da:Sourcerer whitespaces in final output are bytes do download and Firebug does its job very fine
Linux Registered User #364954
GNU/Linux: together we're ready!
Posted 03 May 2012 - 02:47 PM
Well I said gzip because I voted for max indentation, so that gives lots of useless spaces for the browser's interpretation.
gzip (any?) compression algorithm should be effective because we're talking about HTML (text) files.
My home page with very good HTML/CSS separation weighs 18,534 bytes for the HTML alone (230 lines). It's gzipped to 5,256 bytes. With no indentation at all, the same HTML weighs 14,682 bytes. When gzipped, it's 5,039 bytes.
See my point? 200 bytes are imho worth the indentation. And I'm not even using mod_deflate because I don't have it on my shared host.
Now, according to my experience, sometimes proper HTML output indentation is necessary because a closing tag is possible to miss, and browser interpretations can vary, especially prior to HTML5 (which introduces optional closing tags by design). And Safari inspector (the one I use most for HTML) show only beautified/indented and even closed-tag HTML code, so it's not the exact copy of the source. I think I remember FF has the same behavior… but maybe I'm wrong.
Posted 03 May 2012 - 03:47 PM
Output has really nothing to do with the source code - HTML and PHP.
Indentation matters for that.
What gets sent to the browser, however, is none of our concern.
I usually compress the heck out of my CSS too..
Posted 03 May 2012 - 03:52 PM
Yes, indeed. But in my experience, (X)HTML with all unnecessary whitespaces (that includes CRs, LFs and tabs) stripped tends to compress even better. It's all about getting the last bit out of it
Posted 03 May 2012 - 05:51 PM
Also if you consequently stip white spaces you will have to have 2 different view files one for editing and one (stripped) for publishing. Imho its not worth it for HTML.
I do care about indentation, but usually auto format works pretty well, so it's not a big issue for me.
Posted 04 May 2012 - 06:08 PM
Yes, we sometimes have to examine the raw html output to debug. The raw html can have errors like missing opening/closing tags or overlapping tags. But those errors will be covered up by the browsers' parser, and we will see only the corrected DOM tree.
So I admit that cleanly formatted raw html output has some advantage. But it is very small and not worth the effort. We can use our favorite editor to check the matching of tags, and it doesn't matter how beautiful the html is indented when we do that kind of debugging.
Posted 08 May 2012 - 04:30 AM
anyways why indent the html output code? hahaha is there any good man can perfectly indent a html code after it is produced by server-side code to the client-side?
if there is... then TEACH ME!! ^___^
Posted 08 May 2012 - 05:32 AM