I write, and sometimes rewrite, various libraries, and I’ve received the “too many libraries” complain more than once … but let me try to explain what’s behind my Open Source Software ideas.

Photo by Sonja Langford on Unsplash


As Independent Libraries Author

I’m providing pretty much every popular pattern through modules that, once built for production, go from ~1K to max ~10K combined, and yet that’s not even nearly enough to convince developers, apparently looking for smaller libraries, to adopt or try these out.

Are my libraries too small?

Luckily enough, that’s been the case only twice in the last 2+ years of usage, and those two gotchas have been solved within the same day, which is one of the main reasons I don’t usually publish “solve-it-all” software, ’cause time is not on my side:

  • it’s easier to test and fully cover smaller libraries, and make these super reliable for the single purpose they’ve been created for
  • it’s easier to maintain smaller libraries that, if the previous point worked well, don’t actually need much maintenance in the long term
  • it’s easier to orchestrate multiple micro-libraries together, to produce this or that pattern in the best possible way … so

When developers ask me “where is the create-react-app for this?” all I think is that I don’t always use the same structure to develop Web-stack based applications, and offering the best structure per each project, such as static only, lambda based, Service Worker, or Internet of Things, would take time.

The single “always same” thing I usually bootstrap is a rollup + (optionally) babel based structure to publish NodeJS dual modules, and it’s called modulestrap.

npx modulestrap --help

Yet this requires some manual adjustment, in case one needs more rollup plugins, or slightly different setup/outcome, but with this structure I’ve published pretty much everything with backward CommonJS compatibility, ESM, Web and/or NodeJS as target, etc … but that’s it, is a starting point to create anything we’d like to publish, or simply experiment with, maybe also the reason I publish too much, as it makes modules creation a no-brainer.

modulestrap, together with everything else I publish, is a brick to start small and incrementally put together everything else we might need as we go, but this is apparently under-appreciated, or less interesting than scaffolding 500MB of dependencies to have a hot-reloadable “Hello World” … anyway …

Is a community missing?

Having a community is something developers seek for a reason, but in my personal experience, it never really worked:

  • they asked me to create a @cgjs org to help developers contributing to this (at this time old and deprecated) project and, since I’ve done that, not a single contribution happened. It took a lot of time to put together all the modules in a monorepo structure, be sure everything would work, anyone could contribute and … crickets.
  • the @ungap org has 1 maintainer: me. Some of its polyfills is being used in @babel/core but this “should be an org” concept failed again.
  • they asked me to put a hyperhtml tag in Stack Overflow and yet they kept filing issues asking for help instead of using Stack Overflow, so that knowledge, issues, or solutions, were confined in the project’s repository, instead of becoming something to talk about in there.
  • they complained about hyperHTML lack of documentation, and it’s been literally one of the first link on top of the README. Mostly nobody read it, even if linked also in other similar libraries of mine, but I’ve got the “where’s the doc” complain. Don’t get me wrong, the documentation is nearly as good as the other libraries documentation you can find out there, but it’s surely better than the one I’ve provided for other projects, but then again, I was 100% focused on my Open Source projects at that time, while today I don’t have much time in general, and yet I document as I can in each README and, guess what, … most devs don’t read that neither.
  • I’ve ultimately tried to create boards around my libraries, but beside being a forum not super exciting 2020 “new community” format, not much is happening … should I twitter more with real examples? Should I post stuff in there and be a community by myself? I don’t know … but whatever different thing I should do would require time.

On the other side, one of the obvious things that’s happening here, is that without proper marketing, it doesn’t matter if your project is an org, it has a community (it won’t ever have it without marketing), or it has some good documentation, if nobody talks about this or that library, it won’t basically happen.

I am not too good at marketing in general, but even if that was the case, marketing would’ve costed a lot of time:

  • create a dedicated account for this or that project
  • create a decent site with docs and examples
  • talk about the library or the pattern you’re trying to promote
  • tweet, share, repeat

Once again, during hyperHTML days I had the time to do all these things, yet I believe if a developer would like to experiment, or build something through one of my projects, there shouldn’t be a need for all this, if the word of mouth is still effective as I think … yet … crickets!

… and who should use my libraries, anyway?

That means that, theoretically, any junior to senior developer could grab one library and build something, but here again I hear too often “which library should I use? … I’m confused”, beside me providing:

… and yet, developers are confused … but I think the issue is that, once again, nobody reads anything, unless is on everyone else mouth.

Most developers just don’t bother digging more, but surely enough, I should spend more time making my libraries scope and usage obvious … and once again, time “enters the scene”.

Worth also mentioning that, ideally, every developer would know the basics behind the library/framework they are choosing, but I start thinking nobody cares nearly enough, and this is hard to accept for me, as I rarely pick any software to develop anything, if I don’t know what’s going on behind … so that maybe, explaining what’s going on behind might help reducing this confusion … but I’m not too optimistic here neither …

Different Patterns

Today, it looks like developers don’t bother thinking about requirements, they just grab something that does everything, and they usually choose patterns instead of the right tool for the job … so this section is about patterns covered by my most recent micro libraries, and I’ll try to clarify what could be confusing.

To start with, there are actually only 2 core libraries of mine that are somehow overlapping in terms of provided pattern:

The reason for such overlapping is that having less options around, allowed me to write less convoluted code, resulting in smaller bundles, faster execution, and best-in-class performance. Dropping lighterhtml extensibility and some beloved feature to become like uhtml makes no sense, and the same goes for augmentor which has way too many configuration things mostly nobody cares about, so that bumping major to remove features/options doesn’t look right … but that’s it: my micro-libraries are simply the most essential code I can think about, needed to provide the pattern they cover and not much else … but what are these patterns?

If you like React

import {Component, render, html, useState} from 'uland';

const Counter = Component((initialState) => {
const [count, setCount] = useState(initialState);
return html`
<button onclick=${() => setCount(count + 1)}>
Count: ${count}

// basic example, show two independent counters
render(document.body, () => html`
A bounce of counters.<hr>
${Counter(0)} ${Counter(1)}

However, if you really want to write JSX like template literals, still without needing tools to have working code, kaboobie should satisfy that pattern.

Alternatively, you can try heresy out, which uses the transform ability provided by lighterhtml, and requires each component registration, although with name-clashing guards, for an even “closer to JSX” experience, but it’s worth saying heresy is a good choice mostly if paired with its SSR counterpart.

If you like React SSR

On the other side, heresy-ssr is based on basicHTML DOM emulation, which is completely different from template literals only solutions such as uland, so here again there are two patterns:

  • a static template literal based approach to create layouts only
  • a whole DOM world in the SSR, to do with components anything DOM could do, before creating layouts

If you like Vue.js or Svelte

<template is="uce-template">
<style scoped>
span { color: green }

The <span>{{thing}}</span> is green

<script type="module">
export default {
setup() {
return {thing: 'world'}

In few words, uce-template is a 100% Custom Elements based library, which goal is to help defining portable components once, but usable everywhere, directly in the HTML.

Combined with µce-loader, it is possible to stream definitions, as these are found in the page, making uce-template an ideal static/server page companion for graceful, client-side, enhancement.

Of course tooling based alternatives such as Svelte might produce a slightly smaller outcome, but uce-template components are literally portable via copy and paste and usable as stand alone without tooling whatsoever.

If you like Hooks/Vue.js reactive

It comes with various helpers too:

  • µhooks-fx to propagate once changes as done in µland
  • µhooks-nofx to actually do nothing except returning initial values, as done in µland-ssr
  • µhooks-dom to automatically attach effects to returned nodes, also used in µland

When it comes to reactive changes, compatible with hooks libraries, reactive-props is the one exported in µce-template too, and it can be integrated in any project … ’cause bear in mind, pretty much every library of mine work in what you have built already, there’s no lock in, neither explicit underlying requirement.

// create reactive elements
const body = reactiveElement(
{test: ''},
() => console.log('body.test', body.test)

body.test; // ""
body.test = 'value'; // body.test "value"

Last, but not least, hookedElements, based on µhooks, is another graceful enhancement alternative that doesn’t need polyfills and all for ~2K, simulating Custom Elements features, but compatible with literally any DOM element live on the client.

If you like Custom Elements

import {define} from 'uce';define('my-counter', {
init() {
this.count = 0;
this.dec = () => { this.count--; this.render(); };
this.inc = () => { this.count++; this.render(); };
render() {
<button onclick="${this.dec}">-</button>
<button onclick="${this.inc}">+</button>

If you like “vanilla”

import {render, html, svg} from 'uhtml';
// const {render, html, svg} = require('uhtml');

render(document.body, html`<h1>Hello 👋 µhtml</h1>`);

It literally works with everything else I’ve mentioned so far, and like everything else it can be used already in any project of yours, either as graceful enhancement based “re-hydration”, or as SSR and/or Web Workers, thanks to its speedy and even lighter µhtml-ssr counter-part, which can also be swapped with the richer µcontent, able to minify CSS, HTML, and JS on the fly, requiring although various 3rd party libraries with it.

I’d personally start small with µhtml-ssr though, and switch to µcontent only if produced page size is not great, but with compressed outputs, that’s rarely something needed.

It is also worth underlying that µland-ssr works with Web Workers too, while µcontent targets only the NodeJS environment. See that? Different patterns/scenarios one more time, no overlap.

If you like tool-less development

The only tool I use to test modules, libraries, and whatsoever, is called µcdn, which together with µcompress, is able to produce pure, native ESM based experience for debugging or production.

npx ucdn --help# debug pages and modules
# each refresh ensures no cache
npx ucdn --debug

The best feature of this CLI tool, is that code such as:

import {render, html} from 'uhtml';

will be automatically resolved so that every import will be a real ESM import.

Of course, once import-maps will be available, that’d be the best way to go, but until we are there, I find this CLI extremely simple and efficient for quick prototyping and more.

Consider µcdn like the local version of //unpkg.com/library?module, and only once you need to deploy live, consider usual bundlers or, why not, an export via µcontent.

If you like tool-based solutions

Personal Conclusion

  • way too many new Web developers don’t learn HTML, CSS, and JS basics; they just start with something else they feel instantly productive with, or a must know tech to enter the market. I can’t blame them, but I also don’t understand how these developers believe they can succeed in the long term, but I wish they will, as being a developer is a constant learning experience, and it’s never too late to pick up the basics 👍
  • developers don’t care nearly enough about not using tools … and I guess I am old school here, but it’s really hard for me to imagine needing 500MB development dependencies to start a small to medium/big project
  • the market apparently doesn’t care much about people knowing the stack they work on, as long as they use “buzz-thingy” to show an “Hello World”. I come from different times, where you couldn’t find a job if you didn’t know the basics, but I’m nobody to change this trend and I’ll just acknowledge it.
  • if it’s not used, or promoted, by “Big Co” it’s not worth it. Here there’s literally nothing I can do about, except mentioning that some “Big Co” use one of my modules behind the scene, either as dependency or utility.
  • the “need for community” is half a myth: without marketing behind, nobody really cares about a community. They prefer copy/paste Stack Overflow solutions to crawl and they’ll rarely contribute to make the community around the topic, library, or project, better.
  • without time to dedicate to a variety of full-stack oriented projects, it’s hard to gain momentum and maybe start seeing a community around such projects … and time, for personal OSS projects, is never enough.
  • I won’t stop pushing forward the Web I dream about; I’ll keep experimenting my tool-less ideas, but I’ll also try to share more real-world / live examples, hoping this will help developers to better understand use cases they can solve through one of my dozen projects.

After all, there’s surely a lesson I’ve learned this year, so that 2021 will be the year I’ll push less on GitHub, but more on Twitter/Medium, and use the little extra time I have to improve the current documentation around my latest libraries, hoping to see, at the end of the next year, some adoption improvement.

If that won’t happen though, I might as well realize it’s not worth it to even try to provide alternatives, as nobody apparently cares much and, after all, those projects I’m “competing” with, are already very good at “solving-it-all”.

Happy New Year everyone 🥳

Web, Mobile, IoT, and all JS things since 00's. Formerly JS engineer at @nokia, @facebook, @twitter.