avatar
Justin Fagnani @justinfagnani.com

Ah. Yeah, and even the diffing ones often only diff one layer or implicitly key nodes. I wonder if morphdom would work, but I don't think it has a template syntax, it's just a library.

aug 23, 2025, 4:11 pm • 3 0

Replies

avatar
Veikko Eeva @veikkoeeva.bsky.social

I wonder if something from @webreflection.bsky.social ... 🤔

aug 23, 2025, 4:14 pm • 0 0 • view
avatar
Andrea Giammarchi @webreflection.bsky.social

I think Lea is after "hydration" that works out of the living DOM and not out of logic render() or JSX created. uhtml5 should satisfy all requirements but v5 has current glitches with convoluted signals and hydration is not fully there yet. Hydration needs to be SSR instrumented though or it's bad.

aug 23, 2025, 10:15 pm • 3 0 • view
avatar
Lea Verou, PhD @lea.verou.me

It seems a lot of the libraries that did that are old (e.g. Knockout). I wonder why. Impossible to get good performance without DOM ownership or lack of interest?

aug 23, 2025, 4:27 pm • 3 0 • view
avatar
Justin Fagnani @justinfagnani.com

In Lit's case it's perf and simplicity. Doing one reference check to see if you need to render the template anew, or update the DOM parts is just much faster than checking each node.

aug 23, 2025, 6:27 pm • 3 0 • view
avatar
Lea Verou, PhD @lea.verou.me

Yes, for Lit it would defy its very premise (which is very elegant!)

aug 25, 2025, 3:13 am • 0 0 • view
avatar
Rogin Farrer @rogin.dev

Would a combo of morphdom/idiomorph and an HTML templating lib (mustache, handelbars, pug, etc) work? Not quite clear on what the workflow would be for integrating a reactive library with markup it didn't make 🤔

aug 23, 2025, 6:21 pm • 0 0 • view
avatar
Justin Fagnani @justinfagnani.com

I've often considered making a morphdom integration for lit-html...

aug 23, 2025, 6:33 pm • 1 0 • view
avatar
Rogin Farrer @rogin.dev

I’m not super familiar with lit-html source code, but doesn’t it have its own diffing logic? I just worked on a mustache + morphdom combo integration with ReactiveElement at work. Seems to be working well, but not battle-tested yet

aug 23, 2025, 6:37 pm • 0 0 • view
avatar
Justin Fagnani @justinfagnani.com

lit-html doesn't diff. It just checks whether the new template to render is the same as the previous template. If they're the same, just update the bindings. If they're different, replace the DOM. Much faster than a diff.

aug 23, 2025, 6:42 pm • 1 0 • view
avatar
Rogin Farrer @rogin.dev

Oh I didn’t realize that. When you say checking whether the 2 are the same, is it comparing strings of HTML? I’ve been a little paranoid about perf ramifications of morphdom, but haven’t found a better solution. (Other than managing shadow DOM with imperative JS)

aug 23, 2025, 6:48 pm • 0 0 • view
avatar
Nick Williams @wicky.nillia.ms

It leverages a lesser known property of tagged templates: you get a stable reference to the strings array across multiple invocations, so you can just directly compare references. From mdn:

A snippet of JS showing the behaviour of stable references in tagged templates
aug 23, 2025, 7:32 pm • 3 0 • view
avatar
Lea Verou, PhD @lea.verou.me

Wow, TIL!

aug 24, 2025, 10:24 am • 2 0 • view
avatar
Nick Williams @wicky.nillia.ms

I thought I might have been overstating it when I said lesser known, but I guess not!

aug 24, 2025, 12:16 pm • 2 0 • view