Jun 18th 2008

2 comments

XHTML vs HTML rendering speed test

At the time of writing the web is in the midst of a strange situation with respect to XHTML rendering. Modern websites often identify themselves in their head sections as being coded in XHTML, but identify themselves in their HTTP headers as being coded in HTML. This is because Internet Explorer, the crappest but most prevalent web browser, fails to render XHTML code that correctly identifies itself with the application/xhtml+xml mimetype. To work around this authors send their pages with the wrong mimetype, which causes all browsers to fall back to rendering the code as if it were HTML. This is just one of many ways IE makes the web a more broken place than it ought to be. But I digress.

Various arguments have been advanced as to why XHTML might be preferable to HTML, or vice versa. One of those arguments concerns rendering speed. I've seen people argue this as an advantage of both XHTML-style rendering and HTML-style rendering.

Out of interest I hacked together a (fairly unscientific) speed test of Firefox 3's rendering of a page served as text/html vs the same page served as application/xhtml+xml. The page chosen was my own homepage (with a couple of minor modifications). I served it locally via a slightly modified version of nweb, an extremely simple and lightweight webserver. The render time was discerned using javascript, by taking the time in the head of the page and again in an onload handler, and subtracting one from the other. Not sure if that's the best metric but I can't think of a better one.

And the results are... I bet you're really excited now... over 40 page refreshes, the text/html version averaged a time of 385ms, while the application/xhtml+xml version averaged 367ms. Making the XHTML version ~5% faster. Not dramatic or particularly scientific, but kind of interesting.

2 comments

Cezary Tomczyk said:

The rate may result from the fact that the document xml (actually, with a header application / xhtml + xml) is parsed once, and twice the HTML document.

zeitgeist23 said:

>>Cezary Tomczyk said:

The rate may result from the fact that the document xml (actually, with a header application / xhtml + xml) is parsed once, and twice the HTML document.<<

What does this mean? That in fact XHTML would be ~50% faster if it would render only one time instead of two?

Greetings

Comments are disabled. Blame spammers.