Performance: Attribute best practices
MEDIUM IMPACT
This affects page load speed and rendering by controlling how browsers parse and apply element attributes.
<img src="image.jpg" alt="Descriptive text" width="600" height="400" loading="lazy">
<img src="image.jpg" alt="" width="" height="" loading="eager">
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Empty or invalid attributes | Extra parsing | 1 reflow per missing size attribute | Increased paint due to layout shifts | [X] Bad |
| Valid attributes with sizes and lazy loading | Minimal parsing | No extra reflows | Stable paint with reserved space | [OK] Good |