|
| |
| HomeFAQMember listActive usersLatest postsSearch | RegisterLog in |
| olive |
|
Posted on 2026-10-26 16:15 (edited 2026-10-26 16:55) Link |
|
Posts: 74 Joined: 2022-06-29 |
So.. Chrom{e,ium} (WHATWG) has added a pretty neat new thing to HTML: <body> Neat, but not overly useful at the start (other than out-of-order generation of html from scripts..? and it's main use is intended to be JS Frameworks..)<?marker name="foo"?> yabba yabba lots of stuff </body> <template for="foo"> <p>this gets inserted!</p> </template> (note the end ? is optional, for compatibility with XMLish tools) However it also allows for replacing ranges of HTML! <?start name="the-counter"> <span>6</span> <?end> <template for="the-counter"><span>7</span></template> Unfortunately this consumes the markers/insertion-point.. but guess what <?start name="smallest-known-private-key"> <span>712938192830913892103832</span> <?end> <template for="smallest-known-private-key"> <?start name="smallest-known-private-key"> <span>4</span> <?end> </template> You can just re-insert them! ?start and ?end do not technically obey the xml/html tree (they're linear ranges), but they can be nested!This means you can have a range over the entire <body>, and sub-ranges, so you can replace the whole body when you like, but also make smaller changes more often. (they also work inside <head>! but not all inserted things there actually make changes, I imagine that would be a pita to browser devs) Combined with streaming never-ending html pages, this allows for live webpages without JS! Before now this would always have appended to the end of the page only, without css hiding hacks or placing it inside an iframe. Unfortunately an always-loading page is still janky UX.. feels bad, looks as though it's really slow page, and if the connection hiccups the browser considers the page finished/loaded. Now.. there is one little tiny thing brosers have supported for a very very long time designed to avoid that issue: text/event-stream, or EventStream in JS, aka. SSE (server-sent events). This is a really nice, simple text format. id: 9 event: foobar data: line 1 data: line 2 id: 10 ... it's designed for the server to send updates to the client! id & event are optional, event just allows for JS to have a callback per event-type natively, rather than having to do it yourself, and you can add custom keys too (you can even do keep alives by just sending a : with no key or value). If the connection breaks, the browser re-requests the document automatically, with a Last-Event-Id: HTTP header. Meaning to your JS it appears as though nothing changed.This is wonderful, but mainly only used for lumping JSON payloads around, and not much else. Most things also use a JS framework that does their own thing, rather than using this. Now I was wondering, event-stream, combined with a <template for="..."><?start name="...">......<?end></template> in each event (alt. drop the wrapping template element and put it's k=vs on the event iteself), would be wonderful, lovely way to do updating live webpages. But unfortunately this requires a tiny bit of JS at present, otherwise it would be a really simple and nice way for JS-free websites and browsers to do such things.Could be even nicer combined with a way for html forms that when sent don't load a new page (204 No Content supposedly is for this? but doesn't work that way much.) Something like <link rel="html-events" type="text/event-stream" href="/events"/>. (text/template+event-stream?) |
Rendered in 8.067 ms with 646KB memory used
Voxelmanip Forums (Cirrusboard)© 2022-2025 ROllerozxa, et al. |