Closed fabiosantoscode closed 5 years ago
@dogoku Both hyperHTML
and lit-html
may look similar at first glance but don't share much in common with htm
because they generate different output. The former ones act more like a template language that modify the dom themselves. htm
on the other hand works by creating virtual dom nodes via the passed factory function which can come from any virtual dom based framework like react
or preact
. That's something thathyperHTML
and lit-html
will never be able to do.
All 3 libraries are trying to solve templating using tagged template literals instead of jsx, which requires a compile step. Whether they output html strings, dom nodes or vdom, is an implementation detail that the user can decide (assuming the choice was not made for them by another dependency like react)
But your point is valid nonetheless, the 2 libs I mentioned will not work with a framework that depends on vdom.
The output format for HTM isn't an implemention detail, it's the library's sole purpose. It's true the authoring format looks similar to many other solutions, but the point here is that HTM brings that solution to the Virtual DOM landscape.
It's similar in nature to hyperx, but with additional features from JSX like dynamic tag names and spreadable props.
@dogoku. Both HyperHTML and lit-html are libraries that include tagged templates for markup, somewhat similar to htm, but they also render those directly to the DOM. They also have solutions to create components, data-binding, etc. They are competing with every other front end library out there. HyperHTML and lit-html are competitors in the space for non virtual dom template string solutions. Htm is not in that space. Htm is about enabling a JSX-like syntax in the browser for libraries which would normally require a build step to transpile JSX. Htm converts tagged templates into a virtual node for use by libraries that have virtual DOMs. As such, it works with React, Preact, Inferno, Vue, Hyperapp, etc., anything that has a virtual DOM and can use JSX. Thank you so much for this solution @developit
@rbiggs I am aware of the differences between the libraries, but I feel like I'm being misunderstood.
The point I was trying to make is that someone not depending on a framework that requires vdom , e.g using vanilla web components, can choose between any of those libraries since all are trying to solve the same problem (templating using tagged template literals ti avoid a compile step) albeit in different ways.
This is exactly the situation I am facing right now, as I am trying to build a framework that can run without any precompiling for modern browsers (and the reason why I came across this library).
Regardless, it was never my intention to hijack @fabiosantoscode thread, merely hoping to see collaboration between cool libs, so I do apologise about that and hope people will go back to the original topic.
Regarding the original topic here - the two seem to take fairly different approaches. HTM makes every trade-off in favor of size, which makes it relatively unique in this space. What would joining forces mean in this context?
I've long ago created a project like this, TJSX, and I feel we can join forces and create something even better.
Want to do it?