←back to thread

218 points mdhb | 2 comments | | HN request time: 0.528s | source
1. vlucas ◴[] No.44397490[source]
I like the spirit here, but I would argue we need a few lower level APIs built into browsers first instead.

It will be near impossible to get everyone to agree on a standard template system. What the browser CAN do, however, is provide some lower level APIs on how to apply diffs to the DOM in a performant native way.

I would LOVE for something like this to exist in browsers natively:

element.applyDiff(DocumentFragment | string, { method: 'innerHTML' | 'outerHTML' })

This could apply the diff in a way that would be non-disruptive, i.e. it would keep element focus, input values, states in audio and video players, mutate attributes, etc. There are JavaScript libraries that do this like Idiomorph, but a native solution has the potential to be much more performant.

replies(1): >>44398175 #
2. MrJohz ◴[] No.44398175[source]
The article does link to the DOM part proposal, which would be one useful low-level API. It wouldn't work so well for VDOM-based frameworks, but for other frameworks it could simplify how they work and provide additional room for optimisations. It would also be useful for projects without a framework, particularly if the signals proposal was also adopted.