Performance: Card component patterns
MEDIUM IMPACT
This affects page load speed and rendering performance by how card components are structured and styled.
<article class="p-6 bg-white rounded-lg shadow-lg"> <img src="image.jpg" alt="Card image" class="w-full h-auto rounded-t-lg mb-4"> <h2 class="text-xl font-bold mb-2">Card Title</h2> <p class="text-gray-700">This is a description of the card content.</p> </article>
<div class="p-6 bg-white rounded-lg shadow-lg"> <div class="flex flex-col"> <div class="mb-4"> <img src="image.jpg" alt="Card image" class="w-full h-auto rounded-t-lg"> </div> <div class="px-4"> <h2 class="text-xl font-bold mb-2">Card Title</h2> <p class="text-gray-700">This is a description of the card content.</p> </div> </div> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Nested divs with flex inside card | High (7+ nodes) | 3 reflows | Medium | [X] Bad |
| Flat structure with semantic <article> | Low (4 nodes) | 1 reflow | Low | [OK] Good |