开发者

What is the effect on browser performance when the (X)HTML is invalid

When a given (X)Html docum开发者_StackOverflow社区ent doesn't conform to the specified doctype, what is the performance hit on the browser?


Generally, negligible. However, there are some cases that are invalid because of their disproportionally poor performance, see the standard.

Also, some error handling in quirks mode may affect performance. For example, until Firefox 5, Firefox had some rather involved error handling related to image maps, which was limited to quirks mode. Of course, this doesn't depend on complying to any particular specification, but depends on the doctype used. As usual, I suggest using <!doctype html> for the safest, most standards-compliant, and, indeed, fastest handling of your web sites.


I would imagine that the performance hit would be negligible, however the page may look wrong.


Each browser has its own implementation when it comes to correcting broken (x)html. But even our open source glory Firefox had its problems when trying to fix broken html and some complex code will cause noticeable lag on page load. It may be preferable if you need to pass dynamic (but broken) html generated by a 3rd party service to the client, rather than trying to fix it for each request. But, if the content is static or can be cached for a period on the server, fixing it will grant higher SEO, faster page loads, happier visitors.

By the way, apart from extreme cases, we already live in a world of malformed html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜