Forum Moderators: open

Message Too Old, No Replies

Indented Code vs. NonIndented Code

         

wfernley

2:20 pm on Mar 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was curious if I should get rid of my indented code. I want to limit the filesize of each of my web site pages and I thought getting rid of the spaces for indents would do the trick. I was wondering however if this would cause issues with SE’s reading my pages? All of my site is dynamic so I know a lot of it is already not indented.

What do most of you do with indents? Do you want your code to look neat? Or, do you scrap indents to avoid large filesize?

Thanks in advance for your help!

Wes

SincerelySandy

3:05 pm on Mar 9, 2006 (gmt 0)

10+ Year Member



I have some pages that are and some that aren't indented. I usually indent my code in places where I have a <div > tag. I have taken plenty of pages that were full of indents, such as pages that were created with a program, and removed all indents with no discernable effect on my rankings.

wfernley

2:00 pm on Mar 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for your reply.

I will try taking out the indents and see what happens. I guess it just depends on how much code there is. For a huge page it would probably make a big difference in size to not indent.

lethal0r

3:42 pm on Mar 10, 2006 (gmt 0)

10+ Year Member



it wont affect your rankings at all, only readability. i do this on my pages and it can reduce file size by up to 20%.

zCat

3:50 pm on Mar 10, 2006 (gmt 0)

10+ Year Member



While I can't speak for the search engines, I do a fair amount of HTML parsing, and I can assure you indentation is just so much white space. It would be possible to algorithmically detect clean, indented formatting, but I can't see what the advantage would be from the search engine's point of view.

Having clean, easily parsed HTML code is much more important.

LifeinAsia

4:35 pm on Mar 10, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I agree that indenting definitely helps with editing/troubleshooting during development. However, several editors allow you to collapse and hide content inside tags.

A little off-topic, but here's an anecdote in favor of non-indenting:

Several weeks ago we had a customer claim that she shouldn't have to pay the cancellation fee for her reservation because her "receipt" didn't say anything about it. She said she saved the page as proof.

I had her send me the page. Sure enough, it looked exactly like our reservation confirmation page, except it was missing the line about cancellation fees. Also, all the graphics showed as broken.

I looked at the source code and saw all the code neatly indented according to HTML tags. I checked the source code from the site, and of course ours didn't look like that. I looked at her source code some more and saw that the file names for all the images were changed to something like "\dreamweaver\graphics\..."

So it was quite obvious that she (or someone) had saved the file then used DreamWeaver to edit the file and take out the part about the cancellation fees.

If our code had been indented, I might not have looked further to find the DreamWeaver changed paths for the images.

CainIV

6:29 am on Mar 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



it wont affect your rankings at all, only readability. i do this on my pages and it can reduce file size by up to 20%.

All other things being equal, a smaller page size beats a large page size in the search engines...

Food for thought.

caveman

8:07 am on Mar 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm fond of referring to SEO as a game of inches, where little things can matter, especially in tougher categories. But I'm thinking that we might be talking about microns here. ;-)