WebComponents give us so much, but just not quite enough to be usable on their own without a little bit more on top. Reactivity with observable store and templating with event binding are the big missing pieces.
251 karma · joined April 10, 2012
WebComponents give us so much, but just not quite enough to be usable on their own without a little bit more on top. Reactivity with observable store and templating with event binding are the big missing pieces.
They do a lot, but stop just short of being useful without something of a framework on top. I tried hard to use them directly, but found that it was untenable without sensible template interpolation, and without helpers for event binding.
Here's my shot at the smallest possible "framework" atop Web Components that make them workable (and even enjoyable) as an application developer:
https://github.com/dchester/yhtml
It's just ~10 SLOC, admittedly dense, but which make a world of difference in terms of usability. With that in place, now you can write markup in a style not too dissimilar from React or Vue, like...
<button @click="increment">${this.count}</button>
Whereas without, you need to bind your own events and manage your own template interpolation with sanitizing, handling conditionals, loops, and all the rest.If we could get something in this direction adopted into the spec, it would open up a lot of use cases for Web Components that it just can't address as-is.
Reactivity, composability, templates, etc with no dependencies, in ~150 SLOC.
With the WebComponents movement though, we are getting ever closer to being able to rely on native browser functionality for a good share of what frameworks set out to do. We're not all the way to bliss without frameworks, but for what it's worth here is my 481-byte library to support template interpolation with event binding in order to make WebComponents pretty workable mostly as-is: https://github.com/dchester/yhtml
Instead of taking the path of starting with DOM manipulation and then going to a framework as necessary, I've kept really trying to make raw web components work, but kept finding that I wanted just a little bit more.
I managed to get the more I wanted -- sensible template interpolation with event binding -- boiled down to a tag function in 481 bytes / 12 lines of (dense) source code, which I feel like is small enough that you can copy/paste it around and not feel to bad about it. It's here if anyone cares to look: https://github.com/dchester/yhtml
Our answer was to reimplement the Automerge API with different mechanics underneath that allows for a "snapshots + recent changes" paradigm, instead of "the doc is the sum of all changes". That way performance doesn't have to degrade over time as changes accumulate.
Project is here: https://github.com/frameable/pigeon, with some benchmarks: https://github.com/frameable/pigeon/wiki/Benchmarks in the wiki...
The answer is to do it all in strategic moderation: Use a subset of tailwind just for spacing and layout and revel in simple things being simple. Use modular CSS for UI patterns and revel in the readability of your HTML and visual consistency of your UI. And then use custom scoped CSS where required, and revel in interesting things being only as hard as need be, without ruining everything else along the way.
[0]: https://frameable.com/company/tech/how-we-found-sanity-in-a-...
I like the effort, but this is basically admitting defeat. Just naively using template strings and re-rendering the whole app on every change of state _is_ too slow, and so the author falls back instead to rendering via a series of bespoke methods that mix logic and template strings and DOM methods all interspersed. It still has all the shortcomings of 00's-era PHP, or piles of jQuery.
It is possible to do one step better than this still with vanilla js, if you use Web Components / custom elements. That way you can have each type of custom element (todo-app, todo-list, todo-item, etc) have its own render function using template strings, and you can still sneak in custom optimizations (like direct DOM insertion when adding and item to a long list instead of re-rendering).
But in the end, it's just so wonderful to be able to have reactive state and efficiently render your app from the state, and forget about all the rest.
We developed El.js[1] with all of this in mind, to be as little as possible on top of vanilla js and web components, to get the reactivity and efficient rendering.
https://github.com/frameable/el
It's just ~150 lines / 2kb, and leverages existing browser functionality to accomplish most of the hard parts. Has observability, reactive templates, scoped CSS, no need for a build process, etc.
There's a starter repo here if you want to try it out: https://github.com/frameable/el-starter
We build next-generation virtual spaces for working together. Tech stack is WebRTC, Node, Vue, WebSockets.
We are hiring for many positions, but especially interested in augmenting our WebRTC capacity, both human and technical. We run our own fleet of mediasoup-powered SFUs, and are working on all sorts of fun and hard problems:
- Large scale testing with 1500+ participants in a call using real headless chromiums
- Voice detection and noise cancellation with wasm/tensorflow
- Being robust to so, so many shenanigans introduced by corporate "adaptive firewalls"
- Geographically distributed TURN servers
- Connection quality scoring and analytics in mediasoup
More on this position here: https://frameable.com/company/careers/streaming-media-engine...
Also hiring for other positions as well including a designer, full-stack engineers, and a QA engineer. It's fun stuff and we are a ambitious, scrappy, delightful team. Come join us!
For what it's worth, the tech stack is Node / WebSockets / Vue.
This idea really rings true to me. Tight iteration/feedback loops are key. Each cycle should introduce value -- either in the form solving user pain points, or providing product learnings on the way to solving user pain points.
Yes, in the end it might amount to more overhead each cycle, than if the team had put their head down and focused purely on producing. But: you end up where you actually want to be! And despite however confident you were at the outset, where you want to be is probably different than where you thought you wanted to be. With Agile you get to learn that part along the way.
The easy/valuable stuff is obvious, just do it! The hard/useless stuff is obvious too, just let it be. And then the more important decisions come around which hard/valuable stuff to do.
Either way, all that is much clearer when laid out visually...
I think there _is_ support for Webex, even though there's no logo there above the fold.
Sometimes the differences were totally legitimate and justified for the use case, and other times it was easy to just not remember or realize that the permutation we wanted had already been painstakingly crafted elsewhere.
When we took a systematic approach to catalog how we were using buttons, we settled on that yes, we really do want a lot of options, depending on the scale of the interaction, how much emphasis we wanted to put on the choice, etc -- but not the infinite flexibility (and so low reusability) that comes with a free-for-all.
So this has really worked well for us after settling on this approach. How have others dealt with the trade-offs here?
On BigPicture, two bits of feedback for what it's worth:
- Maybe try `user-select: none` while a user is panning? Otherwise I end up inadvertently selecting text sometimes when I try to pan around, especially in Firefox
- I couldn't figure out how to make a given bit of text bigger or smaller, like the demo shows is obviously possible. I did make it happen a few times but then couldn't understand what steps had actually led to the change... Maybe some instructions on that, or just a floating toolbar could help (even though the toolbar-less aesthetic and approach is otherwise pretty nice!)
It can be really useful if you have situation where a colleague is sharing their hi-res screen, when meanwhile you're on a laptop with a lower-res screen, and you want to zoom in on their terminal or some part of the screenshare so that the text there can be easier to read.
We should really expect to be able to see everyone on the call, in Kindergarten calls, and in meetings at work too. We humans are so well tuned to read each others' facial expressions that we have no problem recognizing reactions/sentiments in small video feeds of our friends and colleagues, even at avatar-size resolutions.
Internally, we've done some tests/prototyping where it's completely workable to have 100+ feeds on the screen all at once, even with some "hero" space reserved for the couple of most recent active speakers.
With Epilogue, once you define your models (with Sequelize), from there it's easy to get basic CRUD functionality and endpoints in a few lines of code.