Live regions and the channel
A region can be refreshed over a channel, and the smallest honest form is a delta computed once for every client on the same base.
up · codes below 0x10 — what the client tells the server
No template if the client has one, values alone if they project, one COMMIT when a staged set should become visible.
The frames were understood and there was nowhere to put the answer, so it says so — a silent 200 would be the wrong answer to a real question. A frame arriving from the wrong direction is rejected before anything reads it.
In plain terms
A live region keeps a page current without polling it. The client opens by saying which templates and which base render it holds; the server diffs against that base and sends the smallest form that will do. A thousand clients on the same base cost one diff, because the answer is memoized by the transition rather than computed per connection.
A region marked live can be refreshed over a channel without the page navigating. What arrives is chosen from a ladder of wire forms, and the interesting rung is the smallest one.
One template, three wire forms
examples/pricesThe same fragment, and one price changed. The table under it is the three encodings measured on this render rather than quoted from a benchmark.
Your basket
| Olive oil, 2L | 14 |
| Basmati rice, 5kg | 9 |
| Medjool dates, 1kg | 12 |
Total
app/fragments/examples/prices.tsximport { fragment } from '@weftjs/core'
interface Line {
sku: string
name: string
price: number
}
/**
* The fragment the wire-form comparison on `/guide/live-regions` is computed from.
*
* Nothing about it is special — a heading, a total and one row template — and that is the point.
* `html`, `patch` and `delta` are three encodings of the *same* sealed template, so the byte counts
* beside it are three ways of saying one price changed, not three implementations.
*/
export default fragment(({ heading, total, lines }: { heading: string; total: number; lines: Line[] }) => (
<section class="prices">
<h3>{heading}</h3>
<table class="rows">
<tbody>
{lines.map((line) => (
<tr data-sku={line.sku}>
<td>{line.name}</td>
<td class="num">{line.price}</td>
</tr>
))}
</tbody>
</table>
<p class="total">
Total <output>{total}</output>
</p>
</section>
))
What the compiler knows
Holes
| Binding | Hole | Escape |
|---|---|---|
heading | text | escape |
lines | list | trusted-raw |
total | text | proven-safe |
What the client wires on adoption
No wiring: nothing on this template changes after it is painted, so the client attaches nothing to it.
- Sealed templates
- 2
- Version
3fdd7374ceb2f6e5a794ff4329425df2
The same change, in three forms
One price rose by two. Here is what each form costs for that change, measured on the render above rather than quoted from a benchmark:
| Form | Bytes | Against html | What it carries | What it needs |
|---|---|---|---|---|
html | 367 B | — | the region, rendered | nothing — always available |
patch | 336 B | 8% smaller | the markup of the holes that changed, as DOM writes | nothing resident on the client |
delta | 186 B | 49% smaller | the changed values only | the template, and the base render the client names |
Measured when this page rendered, from the sealed template of
examples/prices and two value sets one price apart. JSON payloads are counted as
written; a socket sends them inside a warp frame, which adds its own header.
The forms, and how one is chosen
| Form | What it carries | What it needs |
|---|---|---|
html | The region’s markup. | Nothing. Always available. |
patch | The markup of the holes that changed. | Nothing resident. |
delta | The changed values only. | The client holds the template and names the base render it has. |
The negotiation is not a preference: every form of a fragment must produce identical bytes, and the benchmark harness refuses to publish a number until it has checked that they do.
Why a delta is cheap for the server too
Because the client names the base render it holds, a delta is a pure function of two content-addressed states — so it is memoised by the transition it encodes. One computation serves every client making the same transition, where a diff kept per connection produces one diff per connection. That is architectural rather than a tuning choice, and it is the claim the harness’s deltas command exists to measure.
Epochs
An optimistic update is staged into an epoch and committed atomically: every region in it flips at once. Rollback is discarding the epoch — nothing was painted, so there is nothing to un-paint and no prior state to reconstruct.