6 ms·
Does anyone have a simple definition/explanation of Web Components? The only descriptions I find online call them "reusable widgets or components in web documen
by ihuman 11y ago
Does anyone have a simple definition/explanation of Web Components? The only descriptions I find online call them "reusable widgets or components in web documents," which is kind of meaningless since all code could be considered reusable.
- jfoutz 11y agoIt lets you bundle up the html, css and javascript in one place. Imagine a video player with css buttons and a video section. you include the component source then put in a <my-player/> tag somewhere. That's the gist anyway. kinda sorta like client side taglibs like you'd see in jsp pages.
- douche 11y agoSo it's like an ASP.NET MVC partial view, with css and javascript defined in the view cshtml file instead of in external files?
- jfoutz 11y agonot so familiar with ASP.NET, but yeah that sounds about right. The key is it runs in the browser itself, rather than being a bundle that's compiled and moved around at build or run time. you take all your standard html5 stuff, bundle it in one file, and serve that to any client that wants a video player. You can, of course, play minification games or whatever to reduce the number of files - but the pure form is, one include == one component.
- itaysk 11y agoI was just going to write it's like ASP.NET Web Forms User Controls. Only that was server-driven.
- marknutter 11y agoThe simplest and most straightforward explanation of Web Components is that they are a way for web developers to create new html tags instead of relying on the browser vendors to do so. For example, you're probably familiar with the <video> tag; it requires no additional dependencies to use, provided your using a browser that supports it, and its styling and internal logic is neatly encapsulated and hidden from the consumer. Web Components will enable you to create such tags and easily share them with the world.
- corysama 11y agoDisclaimer: I am not a web dev. The simplest explanation I've come across is that web components lets you create pockets of html, css, and JavaScript that are self-contained and, importantly, not affected by the actions of external css and JavaScript. The browser vendors originally created it for themselves so that they could do things like build a standardized html5 video player interface using html but without worrying about you iterating over the internal elements in js or screwing up the buttons with css.
- acqq 11y agoSo it's a new way for the "Flash after the death of Flash"?
- justwannasing 11y agoNo. It's a reincarnation of what we should be using all along: XML
- pjmlp 11y agoBasically a way to package a set of HTML, CSS and JavaScript into a reusable table that can appear as if it was natively supported by the browser. A new generation of web developers gets to rediscover desktop native widgets, 20 years later.