views:

103

answers:

4

Does having (approx 100) HTML validation errors affect my page loading speeds? Currently the errors on my pages don't break the page in ANY browser, but I'd spend time and clear those anyhow if it would improve my page loading speed?

If not on desktops, how about mobile devices like iPhone or Android? (For example, N1 and Droid load pages much slower than iPhone although they both use Webkit engine.)

Edit: My focus here is speed optimization not cross-browser compatibility (which is already achieved). Google and other biggies seem to use invalid HTML for speed or compatibility of both?

Edit #2: I'm not in quirks mode, i.e. I use XHTML Strict Doctype and my source looks great and its mostly valid, but 100% valid HTML usually requires design (or some other kind of) sacrifice.

Thanks

A: 

Probably yes, and here's why.

If your code is valid to the W3C doctype you are using then the browser doesn't have to put more effort in to try and fix your code. This is called quirks mode, and it would be logical that if your code were to validate, the browser wouldn't have to try and piece the website back together.

Remembering it's always beneficial to make your code validate, if only to ensure a consistent design across the popular browsers. Finally you'll probably find that you fix the first few errors and your list of 100 errors will drastically decrease.

ILMV
Oh, great. Has someone actually profile both invalid and valid pages for loading times?
Nimbuz
Didn't you confuse quirks (where more parsing effort is needed) mode with standards compliance mode (when nothing needs to be fixed)?
jensgram
+1  A: 

It might affect loading speed, or it might not. It depends on the kind of errors you're getting.

I'd say that in most cases it's likely that it will be slower because the browser will have to handle these errors. For instance if you forgot to close a div tag, some browsers will close it for you. This takes processing time and increase the loading time.

I don't think the time delta between no error and 100 errors would be minimal. But if you have that many errors, you should consider fixing your code :)

marcgg
Right, but JFYI, 100 is kind of low, some huge traffic sites have 300+ :)
Nimbuz
100 is still fairly high, IMO but it depends. What kind of errors are they?
DisgruntledGoat
It really depends on the errors. If it's missing alt tags, I doubt it will impact the loading time. If There's invalid properties all over the place, it's another story.
marcgg
+3  A: 

It doesn't affect -loading- speed. Bad data is transferred over the wires just as fast as good data. It does affect rendering speed though (...in some cases... ...positively! Yeah, MSIE tends to be abysmally slow in standards mode) In most cases though, render speed will be somewhat slower due to Quirks mode which is less efficient, more paranoid and generally instead of just executing your data like a well-written program, it tries its best to fish out some meaningful content from what is essentially a tag soup.

Some validation errors like missing ALT or no / at the end of single-element tags won't affect render at all, but some, like missing a closing tag or using antiquated obsolete parameters may impact performance seriously.

SF.
A: 

In theory, yes it will decrease page load times because the browser has to do less to handle errors and so on.

However it does depend on the nature of the validation errors. If you're improperly nesting tags (which actually may be valid in HTML4) then the browser would have to do a little more work working out where elements start and end. And this is the kind of thing that can cause cross-browser problems.

If you're simply using unofficial attributes (say, the target attribute on links) then support for that is either built into the browser or not. If the browser understands it, it will do something with it, otherwise it will ignore the attribute.

One thing that will ramp up your validation errors is using <br> under XHTML or <br /> under HTML. Neither should increase loading times (although <br /> takes a fraction longer to download).

DisgruntledGoat