CSS Hot Reload
superreload can update CSS stylesheets without refreshing the entire page.
How It Works
When a .css file changes:
- The file watcher detects the change
- A
css_reloadmessage is sent via WebSocket - The JavaScript client finds matching
<link>elements - A new
<link>element is created with a cache-busting query parameter - Once the new stylesheet loads, the old one is removed
This results in an instant visual update without losing page state.
Requirements
Your CSS must be loaded via <link> elements:
<link rel="stylesheet" href="{% static 'style.css' %}">
Inline styles in <style> tags are not hot-reloaded.
File Matching
The client matches CSS files by filename. If you change style.css, it will reload any <link> element whose href contains style.css.
Watched Directories
By default, these directories are watched for CSS changes:
<app>/static/directories- Any directory in
STATICFILES_DIRS
These directories are ignored:
staticfiles/(collected static output)node_modules/
Debugging
Open browser DevTools console. When CSS reloads, you'll see:
[superreload] CSS reload: ['style.css']
And a green toast notification: "CSS Updated"
Errors
If a CSS file fails to load (404, syntax error), the old stylesheet is kept and an error is logged to the console. This prevents your page from losing all styles due to a typo.