Skip to main content

Module livereload

Module livereload 

Source
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

  1. The LiveReloadPlugin hooks into the on_serve lifecycle event.
  2. It walks all HTML files in the site directory.
  3. It injects a <script> tag before </body> that opens a WebSocket connection to a configurable port (default 35729).
  4. When the server sends a "reload" message, the page reloads.
  5. 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§

LiveReloadPlugin
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.