Performance: Login view and template
MEDIUM IMPACT
This affects the initial page load speed and interaction responsiveness when users access the login page.
from django.shortcuts import render from django.contrib.auth.forms import AuthenticationForm def login_view(request): form = AuthenticationForm(request) # lightweight built-in form return render(request, 'login.html', {'form': form}) <!-- login.html --> <html lang="en"> <head> <title>Login</title> <link rel="stylesheet" href="/static/css/login-min.css" media="print" onload="this.media='all'"> <noscript><link rel="stylesheet" href="/static/css/login-min.css"></noscript> </head> <body> <main> <form method="post" aria-label="Login form"> {% csrf_token %} {{ form.as_p }} <button type="submit">Login</button> </form> </main> </body> </html>
from django.shortcuts import render def login_view(request): return render(request, 'login.html', {'form': HeavyLoginForm()}) <!-- login.html --> <html> <head> <title>Login</title> <link rel="stylesheet" href="/static/css/large-style.css"> <script src="/static/js/large-script.js"></script> </head> <body> <form method="post"> {% csrf_token %} {{ form.as_p }} <button type="submit">Login</button> </form> <img src="/static/images/large-background.jpg" alt="Background"> </body> </html>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy login form with large CSS/JS and images | High (many nodes, deep tree) | Multiple reflows triggered by images and scripts | High paint cost due to large images | [X] Bad |
| Lightweight login form with deferred CSS and minimal assets | Low (simple form markup) | Single reflow on initial load | Low paint cost, minimal images | [OK] Good |