clay.js
  1. ClayJS
  2. Reference
  3. Setup
  4. Offline build

Offline build

The standalone build: every module in one file, for pages that load with no network.

The standalone build is every module in one file, for pages that load with no network: core, every plugin and every satellite, built from the same source.

clay.standalone.js#

Download clay.standalone.js

About 5 MB of readable source. MIT-0 for the clayjs code; the third-party notices for the libraries inside are on the first lines of the file. /v1/clay.standalone.js is the newest 1.x; /1.1.0/clay.standalone.js is that exact release, forever. The first line of the file names its version. It is also in the npm package, at dist/clay.standalone.js.

The same tag, pointed at the file#

HTML
<script src="clay.standalone.js?plugins=sync"></script>

Same query params as clay.js: plugins and exclude. Everything is inside the file, so plugins= decides what runs, not what downloads. The satellites are inside too: await clay.loaded.ui, clay.loaded.sap and the rest work without a tag of their own.

Always on means always on: the ui satellite’s automatic Couldn't save and Offline, will retry toasts run on your page, and the element helpers (el.nearest, el.val and friends) are installed, whether or not you asked. Listen for the clay:save-* events yourself if you want your own feedback. If your page already had satellite tags, delete them: a second sap.js mounts a second runtime and every action runs twice.

The file never changes under you. A page depends on the bytes it has, not on a server. You can even paste the whole file into a <script> block; the query params then have nowhere to go, so the defaults apply.

What still reaches out#

Both are opt-in, and both fail soft.

WhatWhenOffline
The CMS sidebar’s font, from jsDelivrplugins=cmsFalls back to your system monospace. The sidebar works the same.
A diff library, from esm.shAutosave debugging, switched on with localStorage.setItem("clay:debug:autosave", "true")The debug log loses its diffs. Autosave itself is unaffected.

Offline still needs a writer#

The library is now on your disk. A host can also carry the library for you: HTML Clay and Hyperclay Local each ship one exact ClayJS release and serve it at /_/clayjs/<version>/, pointing a document’s clayjs.com URLs there when they serve it, late-loaded modules and fonts included, so a page whose tag points at clayjs.com still works with no network. Saving is a separate job: something has to take the edited document and write the bytes. HTML Clay does that on the machine itself, with no network. It serves the file at 127.0.0.1, stamps the save token that lets you edit it, and writes every save back to disk. Wi-Fi off, everything works.

A file opened straight from disk (file://) loads and renders, but has nowhere to post a save to. It stays in view mode unless you force edit mode, and then a save reports an error and your edits stay in the tab.

When you want a newer clayjs#

Download again and replace the file. Nothing else changes: the tag, the params and your document stay as they are. To see what you have, read the first line of the file.

The rolling /v1/ URL updates on its own for pages that load from the network. A file you downloaded does not, on purpose.