Performance: Responsive tables
MEDIUM IMPACT
Responsive tables affect page load speed and rendering performance by controlling how table data adapts to different screen sizes without causing layout shifts or excessive reflows.
<div class="table-responsive"> <table class="table"> <thead> <tr><th>Name</th><th>Email</th><th>Phone</th><th>Address</th></tr> </thead> <tbody> <tr><td>John</td><td>john@example.com</td><td>123-456</td><td>123 Street</td></tr> <!-- many rows --> </tbody> </table> </div>
<table class="table"> <thead> <tr><th>Name</th><th>Email</th><th>Phone</th><th>Address</th></tr> </thead> <tbody> <tr><td>John</td><td>john@example.com</td><td>123-456</td><td>123 Street</td></tr> <!-- many rows --> </tbody> </table>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Table overflow without container | Low | Multiple on resize | High due to layout shifts | [X] Bad |
| Table inside .table-responsive container | Low | Single on load | Low, smooth scrolling | [OK] Good |
| Changing table cells to block on small screens | High | N reflows (N=cells) | High paint cost | [X] Bad |
| Using horizontal scroll with nowrap inside container | Low | Single reflow | Low paint cost | [OK] Good |