Performance: Template inheritance with base template
MEDIUM IMPACT
This affects the server-side rendering speed, impacting the initial page load time.
{% comment %}Base template with blocks{% endcomment %}
<!-- base.html -->
<html>
<head><title>{% block title %}Default Title{% endblock %}</title></head>
<body>
<header>Site header</header>
<main>{% block content %}{% endblock %}</main>
<footer>Site footer</footer>
</body>
</html>
{% comment %}Child template{% endcomment %}
{% extends "base.html" %}
{% block title %}Page 1{% endblock %}
{% block content %}Content for page 1{% endblock %}{% comment %}Each page repeats full HTML structure{% endcomment %}
<html>
<head><title>Page 1</title></head>
<body>
<header>Site header</header>
<main>Content for page 1</main>
<footer>Site footer</footer>
</body>
</html>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Repeated full HTML in each template | No change (server-side) | No change (browser) | Larger templates increase server parsing time | [X] Bad |
| Template inheritance with base template | No change (server-side) | No change (browser) | Smaller templates reduce server parsing time | [OK] Good |