Photo by Mateusz Wacławek on Unsplash

No, this is not yet another rant, neither a duplicate of other posts; this post is rather about important topics not many others discussed to date.

Developers have opinions that could lead to “wars”, where everyone blindly support their idea without listening, or analyzing, all the facts in an objective way, and the NodeJS module’s topic is no exception: frustrating, sometimes infuriating, and dividing pretty much every developer floating around the JS ecosystem, from Front End (bundlers) to Back End (node vs deno vs …).

But as one that has been part of the NodeJS Module Working Group, blindly pushing…

Photo by Anant Chandra on Unsplash

You might already know both WeakMap and WekSet, but many don’t know yet either WeakRef, or the mighty FinalizationRegistry, which are enablers of new, unthinkable, patterns!

This post goal is to describe all these modern primitives, and their use cases.

… we used attach any kind of property directly to objects and/or DOM nodes (also known as expando), likely polluting these objects in the wild, compromising their runtime “shape”, simply to relate any complex value to another.

The only use case, and old time feature, provided by this technique, is that once the generic object gets garbage collected, all these…

Photo by Anna Gru on Unsplash

It was the year 1998 when W3C proposed a way to gracefully enhance, via the CSS’ behavior property, any builtin element on the page that would inherit such behavior defined through one, or more, external .htc files.

<li style="behavior:url(">Example</li>

One limiting factor (…) is that there is no way to formalize the services that an HTML application can provide, or to allow them to be reused as components in another HTML page or application. …

basic JSX transpilation example

I’ve managed to create, thanks to Nicolò Ribaudo, a Babel plugin that solves the issue with static attributes in JSX regular HTML node.

Probably not everyone knows that, React a part, JSX can be used with pretty much any library.

The transpilation is quite simple: let’s see an example!

// this
const jsx = (
<div id="test">
<Component key={"value"} />
// becomes this
const jsx = callback(
// tag name or component
// all properties (attributes)
{id: "test"},
// zero, one, or more children
callback(Component, {
key: "value"

The fragment logic is no exception, it’s…

Photo by Umanoide on Unsplash

After reading yet another blog post about JS classes being “just sugar for prototypal inheritance”, I’ve decided to write this post to help clarifying, one more time, why this statement is misleading; a post that hopefully explains what’s the difference and why it matters to understand it.

Using "use strict" directive in ES5 won’t forbid constructors to be called without new keyword.

// ES5
function Test() { "use strict"; }{}); // it's OK
// ES6+
class Test {}{}); // it throws

The reason is that modern classes have a concept otherwise impossible to replicate in ES5, without…

Lazily evaluating properties is not just handy, but mandatory in some case. This post explains strategies and provides answers regarding this topic.

Where I work, we deal daily with hundred thousand things to eventually parse when needed, and having lazy resolutions, in terms of parsing time, to provide meaningful results on demand is not an option!

Without boring you with too many details, I wanted to understand if the way we are lazy-parsing things is efficient, and here there’s some result.

The Pattern

JS provides many ways to do the same thing, and that’s both awesome and cumbersome, as we don’t have…

Photo by ALAN DE LA CRUZ on Unsplash

Heavily inspired by hyperHTML intents ability, exploring a way to easily migrate from hyperHTML to uhtml, this 3 LOC commit enabled exponential features within the lightest, fastest, template literal engine, of its kind, out there.

The TL;DR version of this post, is that µhtml now accepts interpolations callbacks as elements content, passing along the comment node used to hold whatever value such callback will return: strings, numbers, arrays, … whatever!

A wild uhtml-intents helper appears

Still based on few, size-irrelevant, extra lines of code, the uhtml-intents module does nothing more than register an intent, and be sure this gets executed while rendering.

import {define, intent}…

Photo by JJ Ying on Unsplash

Check my talk at Speakeasy JS 👋

JSDOM is awesome, but it’s slow at pretty much everything, except repeated querySelectorAll, which is a “not so interesting” use case to me.

It’s also something downloaded 14M times per week, accordingly to npm stats, making it the most battle-tested, non-browser, DOM module available: hard to compete there.

There are alternatives too, such as basicHTML, but it never really had momentum and, after my latest tests, I’m glad it didn’t, as it’s surely faster than JSDOM, but it fails at pretty much everything, being born to solve mostly viperHTML and herey-ssr use…

Photo by vaun0815 on Unsplash

There is a “slightly annoying” difference, or better, a limitation, in native ESM import, compared to CommonJS require: it’s not possible to deal with the module system internal cache, hence it’s not possible to invalidate such cache, or tell NodeJS that module-x is actually referring to file://x.js, unless importmap lands officially in NodeJS core too.

… but I’m sure there is a module for that …” and you’re obviously right, although we don’t always control how NodeJS is bootstrapped, as example via serverless services, or server side workers, so I’ve decided to explore a different approach.

A Home Made Registry

The technique I am…

Photo by Alexander Sinn on Unsplash

WebSQL left the Web a while ago, but WebAssembly brought it back, as nothing on the Web is as simple, yet powerful, as this wonderful Open Source project.

This post summarizes my idea behind sqlite-worker, a module that brings sql.js in Web pages and/or workers, and persists through the only option we have these days: IndexedDB.

A quick recap

IndexedDB is the best non-blocking database a developer could desire”, said nobody ever, and the reason is simple:

  • the API is everything but straight forward (low-level is the excuse)
  • querying it makes little sense, as it cannot do much, compared to SQL
  • but hey…

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store