5 ms·
>Web Components will replace your frontend framework Yeah, I very much doubt that. Web Components is basically a suite of browser technologies. It's actually
by jchw 8y ago
>Web Components will replace your frontend framework
Yeah, I very much doubt that.
Web Components is basically a suite of browser technologies. It's actually particularly heavy and I kind of hope it doesn't catch on personally, since it pushes so much to already giant monolithic web browsers.
Frameworks and libraries like React and Angular are tools for developing applications first and foremost. The actual technologies they're backed by doesn't matter, but if you can't reimplement either of them using WebComponents it should probably tell you something about WebComponents:
- It's very opinionated about a lot of things.
- It disagrees with many of the (much more popular) frontend frameworks far too much.
React does a whole lot of things right, and it does them right in a relatively small package with a relatively small API surface, and you can extract the essence into even smaller libraries. With functional components, you can even build React components that have almost no React in them at all, other than JSX.
I don't think we need new complicated technologies to solve the kinds of problems React solves. If anything, we need less, like an alternative to the current DOM model.
Most of the innovations in the frontend world don't seem like they can be cleanly applied to Web Components, or even layered on top of it. And if we want to update it down the road to a new major version, we have to wait for every major browser vendor to have a stable implementation and iron out edge cases/differences. That's not a good bet at all based on how it went with Web Components the first time.
In other words, No Thanks, I'll take my framework.
- davidjnelson 8y agoCurious what you think about React Canvas https://github.com/Flipboard/react-canvas https://github.com/Flipboard/react-canvas
- jchw 8y agoI don't necessarily think everything should be Canvas, but rethinking the way pages render wouldn't be a bad idea. The issue I take with Canvas in particular is that it's poor for accessibility, password managers, and other services. I think part of the reason why the DOM and layout engines are so slow and complicated is just because of years of cruft and whatnot. A minimal layout engine with most the abilities of Flex and Grid would be nice.
- dmitriid 8y agoWe could have had it, but alas: https://terrainformatica.com/2018/12/11/10-years-of-flexboxing/ https://terrainformatica.com/2018/12/11/10-years-of-flexboxi... (and also a comparison: https://terrainformatica.com/w3/flex-layout/flex-vs-flexbox.htm https://terrainformatica.com/w3/flex-layout/flex-vs-flexbox....)
- wwright 8y agoI think most of the rationale is around sharing components easily, at a level separate from NPM/&c. For things like JIRA/Disqus widgets, or for small components shared across otherwise disparate parts of a large site (things like Office 365).
- spankalee 8y agoHow do you feel that web components are heavy? They're a pretty small set of low level APIs, and being native they have no download cost. They're also pretty unopinionated. They only let you define an HTML element and hook it's lifecycle. They let you know where to render (the element instance and it's shadow root), and when to do things (lifecycle). The rest is up to developers, and there are lots of helper libraries with different opinions on how to implement a full element. I think you'll find that some of them, like lit-html, LitElement, and Haunted, have very similar ergonomics and models to React. And much better performance and bundle sizes.
- jchw 8y ago>How do you feel that web components are heavy? They're a pretty small set of low level APIs, and being native they have no download cost. This is a weird misnomer to me. Stuff that's provided by the browser is not magically faster or better. Further, native browser functionality can slow down applications just by existing, like for example Mutation Events (which were removed in favor of Mutation Observers.) In that sense I really dislike what functionality is being loaded onto HTML elements, effectively the lowest level primitive of web apps. >They're also pretty unopinionated. They only let you define an HTML element and hook it's lifecycle. In itself, there's not a whole lot wrong with this... But as fate would have it, the idea that HTML elements themselves should be components is an opinion hotly debated. In Angular 2, you have both directives, AND components that are selected from attributes. In React, the component tree is a fully separate entity from the DOM tree, and components don't even appear in the DOM. To me these are not small details that can be reconciled. Part of what makes React ergonomically nice is that it can generate a nice, clean DOM free of component cruft and scoped CSS or whatever. >And much better performance and bundle sizes. Modern JS app performance is just not that simple. We've got server side rendering with hydration, scheduling rendering asynchronously for better responsiveness, bundle splitting, etc. Simply saying "WebComponents are better because they're faster" means little to me. Is my app bottlenecking on React? Often it's really not. And if React's ~100kb is really killing you, there's plenty of libraries that implement just the basics in much less. Preact is quite good.
- Vinnl 8y ago> And much better performance and bundle sizes. I understand that you're the author of lit-html - would you say that the above is the main selling point of it?
- Andrex 8y ago> "I don't think we need new complicated technologies to solve the kinds of problems React solves. If anything, we need less, like an alternative to the current DOM model." It seems to me as if you're saying: "We don't need new complicated technologies." "Also, we need a new, complicated replacement to the time-tested DOM." This probably wasn't the intent but it exposes the need for web components to be built the way they are: progressively enhanced from what's already standardized in browsers. Web components really aren't that complex, and comparing them to React in this way is a disservice.
- jchw 8y agoYeah, the DOM the web layout engine isn't complicated at all ... display: block; display: inline; display: run-in; display: flow; display: flow-root; display: table; display: flex; display: grid; display: ruby; display: block flow; display: inline table; display: flex run-in; display: list-item; display: list-item block; display: list-item inline; display: list-item flow; display: list-item flow-root; display: list-item block flow; display: list-item block flow-root; display: flow list-item block; display: table-row-group; display: table-header-group; display: table-footer-group; display: table-row; display: table-cell; display: table-column-group; display: table-column; display: table-caption; display: ruby-base; display: ruby-text; display: ruby-base-container; display: ruby-text-container; display: contents; display: none; display: inline-block; display: inline-table; display: inline-flex; display: inline-grid; Of course that's just CSS/the layout engine. The DOM itself is sort of unrelated. But to that effect, I'd like to mention two filesizes. React 16.6.0 base library, minified: 6.21 kb React 16.6.0 DOM integration, minified: 100.39 kb
- BinaryIdiot 8y ago> It's actually particularly heavy Huh? It's a very small API built _into_ the web browser. What's heavy about it? It's kinda similar to how JSX works just with less bells and whistles, more standard web stuff. > It disagrees with many of the (much more popular) frontend frameworks far too much. Ember, React and others plan to eventually support them. So, I am unconvinced that it disagrees with them at all. In fact I think it enables them to have wider access to developers.
- jchw 8y ago>Huh? It's a very small API built _into_ the web browser. Being built into the browser doesn't make it lightweight. I mean, if you look in terms of functions that WebComponents adds, it's a relatively small API surface. However those APIs encompass an awful lot of different functions that imo bloat basic concepts by introducing complexity into HTML elements and the DOM. >Ember, React and others plan to eventually support them. So, I am unconvinced that it disagrees with them at all. In fact I think it enables them to have wider access to developers. I'm very much not holding my breath for that. I do think interoperabilility with WebComponents is a definite future, but thats it. React fundamentally disagrees about what a component is. At the most basic level, React components are not DOM components, their entire DOM representation is what they render. This is not something that can be reconciled. However should React let you export a component as a "WebComponent," via custom elements, sure, that's fine. Interoperabilility is not really notable though. It's also possible to interop React with Angular, Angular 2 with Angular 1, etc etc. Many of those are done today. In big apps. In production. Edit: Reacts take here. https://reactjs.org/docs/web-components.html https://reactjs.org/docs/web-components.html >React and Web Components are built to solve different problems Could not agree more, and that is precisely why no, WebComponents are not replacing my JS frameworks.
- pjmlp 8y agoYeah, React is pretty much anti-browser standard APIs. Vue.js, Angular or vanilaJS are our JS frameworks, exactly because supporting Web Components is part of the culture.
- tflinton 8y ago"I don't think we need new complicated technologies to solve the kinds of problems React solves." Isn't web components the standard, and react is the complicated technology?
- BorRagnarok 8y agoThank you for your constructive argument. I now know I don't need Web Components either ;-)