Skip to main content

sphinx-live-refresh

Quietly reload open Sphinx and Jupyter Book HTML pages when a new build is published, then scroll back to where the reader was.

Unlike local development tools such as sphinx-autobuild, this extension works on published static sites (such as GitHub Pages) with no server-side support — useful when pushing fixes during a lab or lecture while students already have the manual open.

How it works

  • Each successful web HTML build writes a tiny _static/live_refresh.json containing a unique build ID and adds live_refresh_config.js and live_refresh.js to every page.
  • An open page polls _static/live_refresh.json while visible (skipped for local file:// opens and offline builders such as epub).
  • The first response establishes the build the page came from; a different ID later means a new build is live.
  • A visible tab waits until the reader has been idle for a few seconds, is not typing in a form field, has no text selected, and no busy selector matches (open <dialog> elements or active Thebe live-code cells), then saves the scroll position and reloads.
  • A hidden tab reloads immediately, and once reloaded the page scrolls back to where the reader was.

Install

From PyPI:

uv add sphinx-live-refresh
pip install sphinx-live-refresh

From the NB_TUDelft channel on anaconda.org (include conda-forge for sphinx):

conda install -c NB_TUDelft -c conda-forge sphinx-live-refresh

To follow the unreleased main branch instead of a release, install from Git:

uv add "sphinx-live-refresh @ git+https://github.com/NB-TUDelft/sphinx-live-refresh.git"

Enable

In a Jupyter Book _config.yml:

sphinx:
  extra_extensions:
    - sphinx_live_refresh

In a plain Sphinx conf.py:

extensions = ["sphinx_live_refresh"]

No further configuration is required for the defaults.

Configure

All options are optional and use the live_refresh_ prefix:

Option Default Meaning
live_refresh_enabled True Set to False to omit the script and manifest (e.g. for local builds).
live_refresh_poll_interval 60 Seconds between checks while the page is visible (1–86400).
live_refresh_quiet_period 10 Seconds of reader inactivity before a visible tab reloads (0–86400).
live_refresh_busy_selectors ("dialog[open]", ".thebe-cell", ".thebelab-cell", ".thebe-controls") CSS selectors that defer reloading while visible. Set to [] to disable selector checks.
live_refresh_build_id None Explicit build ID written to _static/live_refresh.json (defaults to a nanosecond timestamp per build).

Example in a Jupyter Book _config.yml:

sphinx:
  extra_extensions:
    - sphinx_live_refresh
  config:
    live_refresh_poll_interval: 30
    live_refresh_quiet_period: 15
    live_refresh_busy_selectors:
      - "dialog[open]"
      - ".thebe-cell"
      - ".thebelab-cell"
      - ".thebe-controls"
      - ".my-interactive-widget"

Example in a plain Sphinx conf.py:

import os

extensions = ["sphinx_live_refresh"]
live_refresh_enabled = bool(os.environ.get("CI"))
live_refresh_build_id = os.environ.get("GITHUB_SHA") or None

Releasing

Maintainers: see RELEASING.md. In short, bump the version in pyproject.toml, src/sphinx_live_refresh/__init__.py, and uv.lock, commit, then push a vX.Y.Z tag — GitHub Actions publishes to PyPI and anaconda.org from the tag.

License

MIT — see LICENSE.

Metadata

Release files for sphinx-live-refresh 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-live-refresh 0.1.0
File Size Uploaded Provenance Actions
sphinx_live_refresh-0.1.0.tar.gz 16.7 kB Without provenance Details for sphinx_live_refresh-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-live-refresh 0.1.0
File Interpreter ABI Platform Actions
sphinx_live_refresh-0.1.0-py3-none-any.whl Python 3 none any Details for sphinx_live_refresh-0.1.0-py3-none-any.whl

Total release size: 25.9 kB

Release files / sphinx_live_refresh-0.1.0.tar.gz

Download URL sphinx_live_refresh-0.1.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
da583311fadbede950cade1e27e02fe16b2177e98d3f1308d87bc073e01fc2a7
BLAKE2b-256 checksum
How to use checksums
72d16df1075ced86070d014559ab37e22d7854d12e20d5e9895987ddad5f149d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / sphinx_live_refresh-0.1.0-py3-none-any.whl

Download URL sphinx_live_refresh-0.1.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
263b0fe52ef8891e2941348b75cff8df4c2ce7ef8fbde842d31aa1480d371aac
BLAKE2b-256 checksum
How to use checksums
be27728e8b07a61eaf6c70d5b14f07b5eb8ed17ab951c4bb035aa6461f3ef587
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.13 {"installer":{"name":"uv","version":"0.13.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for sphinx-live-refresh 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page