Skip to content
George Fairs
Go back

Interactive notebooks with marimo (test)

Edit page

A test of embedding marimo notebooks in a post. marimo compiles to WebAssembly, so the Python runs entirely in your browser — no server, which suits a static site like this one. The running example is the logistic map, xₙ₊₁ = r·xₙ(1 − xₙ), a one-line model that slides from a stable orbit into chaos as the growth rate r climbs past ~3.57.

Option A — the whole notebook in an iframe

The simplest embed: the entire notebook, app-style, in a single frame. Self-contained, but it reads as a boxed-in app rather than part of the writing.

Option B — inline reactive islands

The same notebook, but as marimo islands: individual cells embedded inline, sharing one runtime so the slider still drives the plot. The prose between them is authored as markdown cells, so it reads as one flowing document instead of a box:

It takes a few seconds on first load while the WebAssembly runtime and Python packages (numpy, matplotlib) start up.


How this was made: the notebook is notebooks/logistic_map.py. Option A points an iframe at marimo.app, which runs that file from GitHub. Option B is generated by notebooks/gen_islands.py (via marimo’s MarimoIslandGenerator) into src/assets/marimo/logistic.body.html, rendered by the MarimoIslands.astro component; the islands runtime loads from a CDN, so nothing large is committed.


Edit page
Share this post:

Next Post
Hello, world