The iframe handles the journey; my code decides where the arriving document belongs.

Start with the browser's existing machinery

When I click an article, I want the site to become a comfortable place to read it. The header should stay, the selected language should stay, and returning should recover the timeline I was exploring. That is the experience I am designing. A persistent document and a few explicit transitions are enough to describe it.

The useful starting point was htmz: an iframe receives a document, and a small handler moves content from that document into the visible page. Its original convention uses the URL hash to identify the destination. The browser performs the request and parses the response. That division of work immediately appealed to me.

I place that starting point beside two related projects, while keeping their mechanisms distinct. htmx lets HTML attributes describe requests, triggers, targets, and swaps; the server usually answers with HTML. Datastar lets a server send HTML and state changes as SSE events, while its data attributes provide client-side reactivity. My reader takes a narrower path: ordinary article links lead to static HTML fragments, a hidden iframe asks the browser to fetch and parse them, and the reader inserts the article into its persistent page. These projects helped me think about HTML as the medium of interaction. They did not define my resource-slot contract.

The distinction matters because the slot model is my own design. A fragment declares the shared resources it needs; named boundaries in the receiving document say where those resources belong; stable keys let the runtime avoid inserting the same resource twice. The reader uses that contract alongside its iframe-based hypermedia flow. The slot declaration is not an htmz, htmx, or Datastar feature, and I do not want the historical influence of those projects to blur its authorship.

My implementation grows around that mechanism. The browser owns transport and parsing. My code owns the destination, the page layout, dependency insertion, and history. I can inspect each responsibility independently, which matters more to me than giving the result a fashionable architectural name.

A small, explicit replacement contract

In my earlier loader, the hash selected an existing element. The handler examined the incoming body's children, found the child with the matching ID, and replaced the old element. The ID was the agreement between the producer and the receiving document. There was no attempt to infer which arbitrary subtrees were equivalent.

This distinction still matters. A targeted replacement can be entirely sufficient for a static article. My current reader selects the incoming article root, processes its resource declarations, and imports the article into a reading view. It does not perform a recursive DOM diff. I want the operation to be understandable from the HTML that arrives.

If I later need to preserve a playing media element or an edited form inside a replaced region, that requirement deserves a deliberate rule. Today the article body is predominantly static prose. Keeping the replacement boundary clear gives me a small implementation whose behavior I can explain without inventing machinery for hypothetical interactions.

Following one click through the system

An article card carries a real URL pointing to the blog shell with the article path in a query parameter. An ordinary click is handled inside the current document. Modified clicks can still open that shell URL in another tab, where the reader loads the requested article. The shared address represents a reading experience instead of exposing a bare fragment as the destination.

Before leaving the landing view, the reader remembers its current content and scroll position. It then creates the reading layout, updates browser history, and gives a hidden iframe the fragment URL. When the frame finishes loading, the reader obtains its parsed document, processes slots, imports the article node, and removes the temporary frame. A sequence number prevents an older response from replacing a more recently requested article.

article card
    → shell URL + article path
    → history entry + reading layout
    → hidden iframe requests static HTML
    → process resource slots
    → import article into the visible document

browser Back
    → restore landing content and scroll position

Static files are sufficient for the reading side

Nothing in that sequence requires a server to generate HTML on demand. My build already knows the articles, their translations, their dates, and their dependencies. It can write the fragments into folders and leave the deployed site with ordinary files to serve. A GET request retrieves exactly the artifact that the build produced.

This is why the local lighttpd environment and a static deployment on Cloudflare can share the browser mechanism. lighttpd can serve the generated files while I work. In a more dynamic experiment, a CGI script can emit compatible HTML using the same composition tools. The receiving browser cares about the document contract, so the producer can change without rewriting the reading interaction.

I keep those possibilities separate. The public reading path needs static files. CGI is useful for local applications with additional behavior. A crawler that saves CGI output could become another build input, but the current article builder writes fragments directly from YAML. Being precise about that boundary keeps the simple path simple.

History belongs to the interaction

Keeping the document alive creates an obligation: Back must mean something useful. A reader who entered an article from an older month expects to return to that month. Replacing the address without restoring the surrounding experience would leave half the interaction unfinished.

My reader records view state in browser history and restores the landing snapshot when appropriate. It also owns scroll restoration, so the browser's automatic restoration does not compete with rebuilding the view. The article has return links at both ends because finishing a long piece is a natural moment to resume browsing.

There is still a small controller here. I have chosen its responsibilities rather than pretending they disappear. It understands the home view, the article view, their URLs, and their transitions. That is enough routing for this site, and it remains close to the files that actually exist.

The document can bring its own baggage

An article about code may need a stylesheet that the landing page never needed. Moving its visible HTML alone would miss part of the document's requirements. That is where my slots enter the picture: the arriving fragment can declare shared resources, and the receiving page inserts only the keys it has not already seen.

Transport, resource placement, and content replacement remain separate operations. The iframe provides a parsed document. The slot processor handles its shared dependencies. The reader gives the article a place to live. This coordination is the part I find interesting: small mechanisms become useful together without requiring one mechanism to absorb all the others.

The fragment path is same-origin because the reader accesses the frame's document directly. The fragments are authored build output, and the browser runtime uses JavaScript. Those are concrete conditions of this design. Within them, a quiet, fluid reading experience comes from asking the browser to do what it already does well, then adding only the decisions specific to the site.