5 ms·
And lit works without any build tools!
by floatboth 7y ago
And lit works without any build tools!
- nsonha 7y agothe main reason templates are bad is not that it needs a build step, it's more about being non-standard (a problem lit-html doesn't have), and not statically analyzable (think typescript's jsx), which lit-html doesn't solve.
- lenkite 7y agoWeb Templates support slots and are analyzed at definition time. All this is native code supported by the browser so big heavy JS doesn't need go be sent across the network and then run even more slowly in order to produce HTML. All web-template based libraries beat React/Angular/any VDOM based alternative in performance and footprint.
- nsonha 7y ago"...support slots and are analyzed at definition time" I don't know what you meant by this. As we speak, is there a standard implementation of this "Web Templates" thing? Can I open an editor, type "native" html, incorrectly assign to some attribute some callback with the wrong type and the editor tells me it's wrong without running the website? As for "ALL web-template based libraries beat React...", is there evidence to substantiate such claim? Surely SOME of them are not that performant. Also slots exist in most frameworks including Angular and in various 3rd packages in the React ecosystem.
- spankalee 7y agolit-html does solve the static analyzable problem, see https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin https://marketplace.visualstudio.com/items?itemName=runem.li...
- nsonha 7y agothat's interesting to know. Correct me if I'm mistaken since the motivation of the project isn't that clear on the home page: the main thing that makes lit-html special is the fact that it's just standard javascript. This won't appear to typescript developers because they have jsx already built into the compiler. They can use lit-html and have their template type-checked too but it requires extra setup. What's the benefit here? That they can use class= and for=?
- spankalee 7y agolit-html isn't _just_ about using standard JavaScript syntax. It's also about being more efficient than VDOM, very small, and having great HTML integration (you can set any property, attribute, or listen to any event, unlike with React). Yes, you need a plugin for type checking with TypeScript. That doesn't seem to be a huge problem for users so far.
- nsonha 7y agoI appreciate that it's more efficient than VDOM, if it's true and continue to be true in larger scale apps. I don't see "can set any property, attribute, or listen to any event" a benefit though. To me it's such an unpleasant way of writing code to have to keep in your brain a map of all these event and prop bindings. If you need events, Rx is much better to work with. Probably the one thing react is not as good as html elements is the lack of attributes, this causes a lot of defaultValue and shouldComponentUpdate kind of complications. However, if you really think about it all props should just be immutable (attributes) and if you want some to be updated or emit events, just make them Observable and Observer accordingly.