4 ms·
> Who is promising that? This was very much the narrative back when WCs were first announced / released. If that's no longer a focus then what is their selling
by phpnode 7y ago
> Who is promising that?
This was very much the narrative back when WCs were first announced / released. If that's no longer a focus then what is their selling point now?
- csande17 7y agoWeb Components are a very good solution if you're YouTube or Twitter and you want to let people embed your content while providing your own styling/behavior for it. It's basically a lower-overhead version of <iframe> that can set its own dimensions. Web Components are probably also a good solution if you're a news site that serves 90% static text but occasionally wants to embed an interactive chart or something. It's basically a slightly more standardized, isolated version of the `<div id="chart"></div> <script>$("#chart").makeInteractive()</script>`-style code that sites like that normally use. They might also work if you're trying to build a library of standard components (like "toggle switch" or "stepper control") to be used in apps written with a variety of different UI frameworks. Although this depends on good "cross-framework" support which hasn't really materialized yet. Web Components might not be the best solution if you want to render your entire site in client-side JavaScript, SPA-style. But on the whole, there aren't many websites that want to do that—remember, 30% of the Internet is WordPress blogs!—and there are even fewer where it's actually a good idea.
- dfabulich 7y agoYou could use WCs for that stuff, but WCs aren't best for those purposes. 1) YouTube/Twitter widget: Use an iframe, because WCs don't render at all with JS disabled. 2) Interactive chart: You don't need WCs for this case; they make nothing easier and many things harder. Just use DOM APIs directly if your requirements lightweight, or use a popular framework if you need more support. 3) Standard library: That's the interop problem they're talking about up thread. That's literally the only thing WCs are good for, and even then, the fact that they don't render at all with JS disabled means that they're never going to be better/faster than rendering UI server side.
- csande17 7y agoI think web components fall back to regular elements if JavaScript doesn't run. So <twitter-tweet>Cats are the best!</twitter-tweet> and <button is="very-fancy-material-design-button">Click here!</button> would still show up for JS-disabled users, they just wouldn't have the extra JavaScript functionality.
- phpnode 7y agoIn practice this would be <twitter-tweet id="424242424242"></twitter-tweet> What you're saying is true only for the simplest of components.