Performance: Search and filter options
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by controlling how much data is processed and sent to the browser.
filtered = Model.objects.filter(name__icontains=search_term) # Filtering done in database query
results = Model.objects.all() filtered = [item for item in results if search_term in item.name] # Filtering done in Python after fetching all data
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Filtering in Python after fetching all data | High (many DOM nodes) | Many reflows due to large DOM | High paint cost | [X] Bad |
| Filtering in database query | Low (few DOM nodes) | Single reflow for filtered results | Low paint cost | [OK] Good |