Performance: Passing data to partials
MEDIUM IMPACT
This affects page load speed and rendering performance by controlling how much data is sent and how many partial templates are rendered.
<%= render partial: 'item', collection: @items.includes(:associated_data) %><%= render partial: 'item', collection: @items %>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Passing entire objects with all data | N partial renders | N reflows | High paint cost due to large HTML | [X] Bad |
| Passing limited, preloaded data | N partial renders | N reflows | Lower paint cost with smaller HTML | [OK] Good |