Live data from Hacker News

The Failed Promise of Web Components

lea.verou.me

11–20 of 235 posts

Re: The Failed Promise of Web Components

#11
post #7

I recently stumbled across "shoelace", which at a glance seems like an example of what the article is hoping for. It's a thoughtfully designed library of UI web components. https://shoelace.style/

... and it suffers from the same oversight every other web component library (polymer, mdl) suffers from: - I can't swipe left/right between the tabs - I can't pull the menu out from the left by swiping the entire page right Two of the most basic touch navigation metaphors aren't supported. To be fair, Polymer and MDL don't support the above either. But this is why HTML5 apps are still not up to par with native apps.…

I could see arguments for keeping that sort of behavior out of a base library. I've never had to implement a menu that swipes out like that, but I could see it being a complex behavior to get right.

if you need that use case, it seems easy enough to implement

Re: The Failed Promise of Web Components

#12
post #6

I completely agree with the author that WCs fail to push more behaviors into HTML. As she describes, you really want to be able to import the WC's script and then have new useful HTML tags. I use LitElement pretty extensively, which is a wrapper around WCs, and I like it quite a bit - but it's only a minor improvement in my mind compared to React, and that improvement is just reducing the abstractions from the DOM AP…

My impression is that JS has led WCs for the simple fact that JS is easier to polyfill/prollyfill/ponyfill and there's a lot more infrastructure today for JS modules and JS bundling. Web Components have been a lot of trying to assemble the cart behind you while riding the (JS) horse, simply because web standards are so slow. (I'm not sure if that analogy entirely works, though in my head it adds the unsightly picture that at least some of the material you have to build the cart with is manure, and WCs being built more than partly from JS manure does sound accurate.)

ES2015 modules are about at the point that caniuse statistics show them as nearly viable for production work, with HTTP/2 (or 3) deployment being possibly the last puzzle piece for a global lessened reliance on bundling for performance reasons. (Though not for simplicity of usage reasons: it's still useful to be able to drop an entire third party bundle all at once on a file host and use the thing as a single import.)

Meanwhile, CSS Modules are still something prollyfilled by JS bundlers and there still isn't an official spec yet?! And "HTML Modules" is so barely on the drawing board that it would be optimistic to call what JS bundlers are doing there as anything resembling a "prollyfill" (we're to "wishfill", I guess?). (And most JS WCs are using virtual DOMs or JS-native template tools instead of HTML templates anyway.)

Re: The Failed Promise of Web Components

#13
post #6

I completely agree with the author that WCs fail to push more behaviors into HTML. As she describes, you really want to be able to import the WC's script and then have new useful HTML tags. I use LitElement pretty extensively, which is a wrapper around WCs, and I like it quite a bit - but it's only a minor improvement in my mind compared to React, and that improvement is just reducing the abstractions from the DOM AP…

Would it help if we made a standard for communication between web components, so whatever tools they use internally, you can wire them into your code or to each other?

Web components are abstraction boundaries, and you have to define boundaries carefully or you still end up with a big ball of mud, now with extra layers of indirection to make your life even worse.

Re: The Failed Promise of Web Components

#14
I love her description of using a dependency-laden component:

> Using a custom element from the directory often needs to be preceded by a ritual of npm flugelhorn, import clownshoes, build quux, all completely unapologetically because “here is my truckload of dependencies, yeah, what”. Many steps are even omitted, likely because they are “obvious”. Often, you wade through the maze only to find the component doesn’t work anymore, or is not fit for your purpose.

That is so true. The "unapologetically" thing is important. I see this all the time. There's often a fair bit of 'tude, where I am looked at with condescension, for not knowing something "obvious."

The fig tree pic is perfect.

EDIT: Removed phrase that was possibly corrosive to the narrative.

Re: The Failed Promise of Web Components

#15
post #6

I completely agree with the author that WCs fail to push more behaviors into HTML. As she describes, you really want to be able to import the WC's script and then have new useful HTML tags. I use LitElement pretty extensively, which is a wrapper around WCs, and I like it quite a bit - but it's only a minor improvement in my mind compared to React, and that improvement is just reducing the abstractions from the DOM AP…

The important thing about web components is that we _can_ import the component's script and then have new useful HTML tags.

You can drop this on a page and it _just works_:

    
    
And this is built with LitElement.

Live demo: https://jsbin.com/kicelemara/2/edit?html,output

Having dependencies doesn't change the external interface to an element, or prevent it from being drop-in. Dependencies are very often good, because they are well tested implementations of a common need, rather than ad hoc implementations that may be brittle or duplicative.

Re: The Failed Promise of Web Components

#16

Man I remember reading about web components some years ago after reading up on Poylmer Dart. It seemed like they were destined to become a common standard for building web apps soon(tm) but I guess frameworks like React blew up a lot quicker.

They are a common standard for building web apps.

Dart itself hasn't kept up with web standards in general, but that's another story.

Re: The Failed Promise of Web Components

#17
post #8
post #4

It would have helped a lot if JS had a working modules systems on the web. > What hope do those who can’t write JS have? Using a custom element from the directory often needs to be preceded by a ritual of npm flugelhorn, import clownshoes, build quux, all completely unapologetically because “here is my truckload of dependencies, yeah, what”. JS has been in a dark & ugly spot, & WebComponents feeling janky & weird is…

Another "big issue" (for me as I develop first on FF) is that Firefox developers refused to implement HTML import. That'd simplify much of using web-components. I include it and the browser can automatically use HTTP2 to load all the components quickly. It'd be interesting to see how much web-components could be pushed using only CSS via things like the "space toggle" trick ( https://github.com/propjockey/css-sweeper…

The JS module system is actually better suited for this.

And ultimately HTML imports don't solve any of the cross-package import issues that JS modules are still trying to solve.

Re: The Failed Promise of Web Components

#18
post #4

It would have helped a lot if JS had a working modules systems on the web. > What hope do those who can’t write JS have? Using a custom element from the directory often needs to be preceded by a ritual of npm flugelhorn, import clownshoes, build quux, all completely unapologetically because “here is my truckload of dependencies, yeah, what”. JS has been in a dark & ugly spot, & WebComponents feeling janky & weird is…

caniuse statistics say that ES2015 module support has reached something like 92% of browsers:

https://caniuse.com/es6-module

Re: The Failed Promise of Web Components

#19
Fully agree with the author.

My biggest complaint about web components is that I don’t see a lot of advantages over using React, Svelte, or some other JS library. The author hints at this: if I’m already committing to a big JS build process, why wouldn’t I reach for one of these more ergonomic JS tools? Warm fuzzies for trying to use open standards isn’t enough to convince most people to switch away from more popular JS solutions.

Re: The Failed Promise of Web Components

#20
This post is needlessly snarky, but I don't disagree with the basic premise.

Here's what killed web components: lack of native databinding on the web. That's the reason the standard is useless without JS. Any modular, dynamic, modern UI requires databinding, which means it's going to bring in a framework anyway, which means that self-contained widgets are all going to bring in their own frameworks, which means that instead of one large framework on the page you have five or six, all of them stitched together through rickety HTML-attribute APIs and custom value-parsing strategies because HTML attributes are just strings.

I fail to grasp why databinding hasn't made it into a web standard yet. The web has a long tradition of feeling out features in the JS world before adopting the successful ones into the platform. jQuery turned into querySelector() and fetch(), CommonJS modules blazed the trail that led to ES modules, etc. And this next paradigm is more than ready to get standardized. Not only would it make the dream of web components possible, it would eliminate the need for a whole lot of the JavaScript out there and even make UIs faster, since reactivity logic would be implemented natively.

It's such an obvious, ubiquitous improvement to the web that I can only assume there's some fundamental implementation roadblock I'm missing.

Post reply on HN