Forum Moderators: open

Message Too Old, No Replies

Does Defining a Doctype Increase Loadtime?

         

mcmrob

10:35 am on Feb 8, 2005 (gmt 0)

10+ Year Member



Say I have defined my document type as:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

What does a browser do with this "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" address? Does it download the Doctype information (the dtd file), increasing the load time (by 30kb)? Or are these doctypes installed in the browser? If so, what about older browsers?

encyclo

6:46 pm on Feb 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The browser does not ever download or parse an external DTD when serving pages with the mime type
text/html
(which is virtually everything). The doctype needs to be present for two reasons: firstly to allow the page to validate [validator.w3.org], and secondly to enable standards compliance mode [webmasterworld.com] which will make you page behave to standards in modern browsers.

It does not slow the page down at all, except for the few extra bytes it uses.

mcmrob

10:03 pm on Feb 8, 2005 (gmt 0)

10+ Year Member



Excellent. Thank you!

jfjet

5:59 am on Feb 10, 2005 (gmt 0)

10+ Year Member



If you don't specify DOCTYPE, the browser will actually assume a "loose" dtd, which actually goes to an extra conditional turn in the code. Meaning it'll be so slightly longer to parse an document w/o a DOCTYPE than one w/ doctype specified.

Of course, that little extra parsing is completely negligible, and absolutely undetectable on the client side even if they are running on an ancient 386 PC.