Performance: Template permission checks
MEDIUM IMPACT
This affects page rendering speed and interactivity by controlling how much logic runs in templates and how often templates re-render.
{% if can_view %} <button>View</button> {% endif %} # 'can_view' passed from view context after permission check{% if user.has_perm 'app.view_item' %} <button>View</button> {% endif %}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Permission checks inside template | Multiple conditional DOM changes per check | Triggers reflows for each conditional element | Higher paint cost due to layout shifts | [X] Bad |
| Permission checks done in view, flags passed to template | Minimal conditional DOM changes | Single reflow for layout | Lower paint cost, stable layout | [OK] Good |