lmjtfy.git / ds-bundle

Chapter 15: ds-bundle, the one script the page loads

Most websites load JavaScript from somewhere else. This one loads exactly one script, and it comes from here: Datastar, a small library that lets the server drive the page. The browser posts what was typed, the server streams back HTML, and Datastar swaps it into place. That is the whole client side of chapter 2's "the browser holds no state".

datastar.js is v1.0.4, upstream's own release build, the same file ~/dashboard serves. The Worker embeds it at build time and serves it at /datastar.js, so the site's own code comes from the site. Two scripts do not: mermaid, on the code pages only, pinned from jsdelivr; and Cloudflare's Web Analytics beacon, which Cloudflare adds to every page as it passes through (chapter 2, "What Cloudflare keeps").

Aside. Why vendor it instead of a CDN link? Pinned bytes in the repository cannot change under you, cannot be taken down, and cannot be swapped by somebody else's server. When it moves, it moves in a commit.

For the people who maintain it

To move it, replace the file with a newer release build and check the page's data-* attributes against that release's syntax.

FileWhat
datastar.jsDatastar v1.0.4, upstream's build. Not edited here.

← Previous: Chapter 14½, eval/src/ · Up: lmjtfy · Next: Chapter 15½, third-party/ →