Performance: DOCTYPE declaration
MEDIUM IMPACT
The DOCTYPE declaration affects how the browser renders the page by triggering standards mode or quirks mode, impacting rendering speed and layout accuracy.
<!DOCTYPE html> <html lang="en"> <head><title>Page</title></head> <body>Content</body> </html>
<html> <head><title>Page</title></head> <body>Content</body> </html>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No DOCTYPE (quirks mode) | Same DOM nodes | Multiple reflows due to layout instability | Higher paint cost from layout shifts | [X] Bad |
| With <!DOCTYPE html> (standards mode) | Same DOM nodes | Single reflow with stable layout | Lower paint cost with no layout shifts | [OK] Good |