Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

sublvl's front end developer seems to have a strange coding style that I've never seen before. Every time they begin a new element, immediately after the element name they insert a line break. The first thing that appears on the next line is the first attribute of the element. For example:

id="player-container"><div
id="player-bar"><div
id="player-controls-wrapper"><div
id="player-controls"><div
id ="player-controls-buttons"> <a

The above code was found here.

I've never seen this kind of coding style before. What's going on here? Is this just a quirky style or is there some reasoning behind it?

share|improve this question
    
[Voting to close.] Who cares? Whitespace is irrelevant. Note, though, that code was minified. –  Su' Sep 6 '12 at 17:41
3  
@Su' Well, clearly I care since I posted the question. It's an idiosyncratic coding style that might have some non-obvious reason or benefit. –  Matty Sep 6 '12 at 18:01
    
It's not a coding style, at least in terms of a person doing it. It's minification. I can't imagine a single benefit of this output to a human. The rule isn't even as simple as you describe: elements that don't have attributes aren't broken across lines, suggesting it's a simple form of whitespace removal(and why only the first attribute?). Script tags are also left alone, as they're more vulnerable to breakage. There's likely other exceptions. As far as people, that's just confusing. Scanning for opening tags at the end of lines is ridiculous from a human perspective. (And so on.) –  Su' Sep 6 '12 at 18:42

1 Answer 1

It appears to be minification by the W3 Total Cache WordPress plugin. This strategy of inserting a line break at the end of the element name seems to be to prevent the line length from becoming too excessive, while taking advantage of the fact that a line break is valid white space for separating tokens in HTML.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.