Expand description
WebSocket-based live-reload script injection. Live-reload script injection plugin.
Injects a WebSocket-based live-reload client into all HTML files in the site directory when the development server starts.
§How it works
- The
LiveReloadPluginhooks into theon_servelifecycle event. - It walks all HTML files in the site directory.
- It injects a
<script>tag before</body>that opens a WebSocket connection to a configurable port (default 35729). - When the server sends a
"reload"message, the page reloads. - On disconnect, the script auto-reconnects with exponential backoff (1s, 2s, 4s, capped at 10s) and shows a small “Connecting…” indicator in the bottom-right corner.
Structs§
- Live
Reload Plugin - Plugin that injects a live-reload script into all HTML files.
Constants§
- DEFAULT_
PORT - Default WebSocket port for the live-reload server.
Functions§
- css_
reload_ message - Returns a WebSocket message for CSS-only reload.