Performance: Static file organization
MEDIUM IMPACT
This affects page load speed by controlling how quickly static assets like CSS, JavaScript, and images are served and cached.
app = Flask(__name__, static_folder='static') # Organize static files into subfolders like css/, js/, images/ # Use Flask's built-in static file serving # Add cache headers via web server or Flask extensions # Example folder structure: # static/css/style.css # static/js/app.js # static/images/logo.png
app = Flask(__name__) @app.route('/static/<path:filename>') def static_files(filename): return send_from_directory('static', filename) # Static files are placed in a single folder without subfolders or versioning.
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Flat static folder with no caching | N/A | N/A | High due to delayed CSS/JS | [X] Bad |
| Organized static folders with caching | N/A | N/A | Low due to fast asset delivery | [OK] Good |