Performance: Responsive theme patterns
MEDIUM IMPACT
Responsive theme patterns impact page load speed and rendering by controlling how CSS and assets adapt to different screen sizes, affecting LCP and CLS.
/* Use mobile-first approach with minimal media queries and combined rules */ .container { width: 100%; padding: 15px; } @media (min-width: 769px) { .container { width: 750px; padding: 20px; } } /* Use srcset and lazy loading for images */ <img src="small.jpg" srcset="medium.jpg 768w, large.jpg 1200w" loading="lazy" alt="Example image" />
/* Using many complex nested media queries with redundant CSS rules */ @media (max-width: 768px) { .container { width: 100%; padding: 20px; } } @media (max-width: 768px) { .container { padding: 15px; } } /* Loading large images for all devices without optimization */
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Complex overlapping media queries with large images | Low | Multiple reflows on resize | High due to large images | [X] Bad |
| Mobile-first CSS with combined media queries and responsive images | Low | Single reflow per breakpoint | Low due to optimized images | [OK] Good |