Not sure how this is any more natural than JSX/HTML. It looks much messier and harder to follow. Also I’d like to see how they handle mount/unmount logic like event listeners.
No shadow dom, so no mount/unmount logic ! A whole new DOM sub-tree is re-created each time a value change. There is an example in the tutorial about how state are handled [1]. [1] https://vanjs.org/tutorial#state-binding
VanJS (Vanilla JavaScript): smallest reactive UI framework
161–170 of 214 posts
Re: VanJS (Vanilla JavaScript): smallest reactive UI framework
#162Why is everybody so obsessed with size? 100kB means nothing these days.
Re: VanJS (Vanilla JavaScript): smallest reactive UI framework
#163The "Hello World" example is a really good example of why React, Vue, etc are better than something more minimal like this library if you're optimizing for speed. The page will show nothing until the script runs, which requires downloading the VanJS lib and the script itself. You could inline them into the page, but that gets seriously messy at scale. A modern React app that's using some serverside rendering for the…
Re: VanJS (Vanilla JavaScript): smallest reactive UI framework
#164They assume that HTML is a closed system with no new tags, and don't account for custom elements or new tags. It doesn't even have support for existing tags like , , or ( is used by some systems now for icons). It doesn't appear to have a way to emit comments.
We have the ability to embed real HTML strings, with expressions, directly into JS, which means that the rendering library doesn't have to have any knowledge or opinion of what the tags are.
This is what Lit does with lit-html templates. The example in the Van readme would be:
const Hello = () => html`
Hello
World
VanJS
`;
Such template strings can contain any HTML - any tag, comment, attribute, entities, SVG, etc.Re: VanJS (Vanilla JavaScript): smallest reactive UI framework
#165Earlier quoted context omitted.
Suggestion: call it Bourbon JS. Wikipedia: > The majority of the world's vanilla is the V. planifolia species, more commonly known as Bourbon vanilla.
Wait people write JavaScript without drinking bourbon?
Also, yes, bourbon (spirit) is a good accompaniment to late nights in JavaScript.
Re: VanJS (Vanilla JavaScript): smallest reactive UI framework
#166Earlier quoted context omitted.
Yes, please be that guy. Or I'll do it. Vanilla Javascript refers indeed to "javascript without a framework". So creating a framework and calling it "vanilla javascript" is... wrong?
Vanilla.js is the most popular framework in the world!!!! http://vanilla-js.com Also has the smallest footprint: 0 bytes uncompressed, 25 bytes gzipped!
Re: VanJS (Vanilla JavaScript): smallest reactive UI framework
#167The "Hello World" example is a really good example of why React, Vue, etc are better than something more minimal like this library if you're optimizing for speed. The page will show nothing until the script runs, which requires downloading the VanJS lib and the script itself. You could inline them into the page, but that gets seriously messy at scale. A modern React app that's using some serverside rendering for the…
The page will show nothing until the script runs If you know what you are doing you can achieve full state restoration of a large SPA before CSS paints to the screen. In my personal app I am able to complete state restoration within the first 80ms of page load on old hardware. Vue and React are not capable of providing this.
Re: VanJS (Vanilla JavaScript): smallest reactive UI framework
#168HTML-builder APIs like this are a pretty bad idea, IMO. They assume that HTML is a closed system with no new tags, and don't account for custom elements or new tags. It doesn't even have support for existing tags like , , or ( is used by some systems now for icons). It doesn't appear to have a way to emit comments. We have the ability to embed real HTML strings, with expressions, directly into JS, which means that th…
If you use a template string like that then you lose a lot in terms of type checking/IDE tooling/etc unless you add a ton of complexity, which is antithetical to this library’s goals. I definitely think they went with the right option.