4 ms·
"In Svelte, an application is composed from one or more components. A component is a reusable self-contained block of code that encapsulates markup, styles and
by bastijn 10y ago
"In Svelte, an application is composed from one or more components. A component is a reusable self-contained block of code that encapsulates markup, styles and behaviours that belong together."
So, the idea is to be kind of like Web components? Even after reading the comments in this thread and the website it is hard for me to grasp where Svelte's place is. Is it for people who need the performance without giving up the work flows of the regular frameworks they are so used to? If it is for encapsulation I would say webcomponents is the better choice here? Although you could argue Web components isn't ready yet either for the big masses.
- rich_harris 10y agoVery much like web components, except a) they work everywhere without polyfills, and b) they're nicer to build, because they have a friendlier API and templates are more declarative (with web components you still have to do a lot of grubby manual DOM manipulation) and you don't have to learn a bunch of confusing new shadow DOM stuff just to encapsulate styles. Also, with Svelte you can do server-side rendering, which is a bit of an oxymoron with web components.
- bastijn 10y agoa) is a bit of a weak argument as polyfills are a temporary solution until browser support is available everywhere. Also, Web components are (indirectly) part of the W3C spec so browser support will follow. B) OK. Though subjective. C) Active support for this is a nice thing to have. Guess it ain't enough for me to use hut I see its use for others. Still, YAJF as far as I'm concerned.
- rich_harris 10y ago> polyfills are a temporary solution until browser support is available everywhere Well, you might be waiting a while! Web components are actually four separate specs. While templates are widely supported, the future for custom elements, shadow DOM and HTML imports is less clear (well it's very clear for HTML imports — it ain't gonna happen). Edge is 'considering' whether to implement shadow DOM and custom elements, Firefox says they're 'in development' but from the outside it looks like that development has stalled. Even if web components had major advantages that outweighed their disadvantages, personally I'd be very hesitant to use them until browser vendors make their intent to support them much clearer.
- bastijn 10y agoI agree, hence the last line in my original reply. Web components are not yet ready for (most) production work. Too be honest I'm happy the only work I do in the Web area is an SDK. We chose to use vanilla javascript and typescript over a framework as any framework should be able to pick us up. I worked with a couple of frameworks the past 2-3 years and didn't like any of them. Of course Web is relative new and it takes time to mature. For now, I'll take a pass on this one but keep an eye. They are closest to anything I could use, but let's see what a little maturity brings it.