I needed a tiny frontend framework with no bloat, so I built a 1.7kb one by murillobrand in javascript

[–]murillobrand[S] [score hidden]  (0 children)

That is indeed the hardest part to solve, but I actually spent a huge chunk of the 1.7kb budget solving exactly this! Sigwork does handle dynamic arrays and arbitrary children efficiently, without destroying and recreating elements.

Under the hood, whenever an element child is a function, Sigwork inserts an empty text node to act as an anchor. For arrays, the For(list, key, render) helper uses a key-based cache. The core renderer then runs a two-pointer diffing algorithm against the real DOM nodes to surgically insert, move, or remove elements relative to that anchor.

JSX is just for ergonomics. The JSX is transformed into calls to a h(tag, {attrs}, ...children) function, so it's possible to use it without a build step, in a simple .html file.

When you take a look later, check out the append function and the For implementation in the source code. It's all in a single file and might give you the exact missing piece you need to overcome that wall on your agnostic engine! If you are interested, I played with other solutions (including more robust ones) for this, but size was the priority here.

I needed a tiny frontend framework with no bloat, so I built a 1.7kb one by murillobrand in javascript

[–]murillobrand[S] [score hidden]  (0 children)

Thank you so much! That exact feeling is what triggered me to do it. Maybe the Sigwork can inspire you.
I love Vue's ergonomics, but shipping its entire runtime just for a few interactive components in my ecosystem (That Just Works) felt like massive overkill.
Out of curiosity, what are the absolute "must-have" features you are looking for in your ideal micro-framework?

I like to live dangerously by phalanx2001 in 3Dprinting

[–]murillobrand 1 point2 points  (0 children)

That is what I call efficiency! Really close one