Skip to content

HomeBlog

Why We Kept JavaScript Out Of Hatamoto

6 min read
𝕏in

Almost every new CMS I look at has a JavaScript framework somewhere in the stack. React in the admin, Astro or Next on the front end, and a build pipeline holding it all together that is sometimes hard for devs to keep track of.

Hatamoto does not have any of that. There is no package.json in the repo and no node_modules folder. You run go build and you get the whole CMS as one binary - the site, the admin, the REST API and the MCP server. This includes many of the paid plugins built in the core. One estimate is close to $1200 worth of free plugins built in.

People don't understand this decision including criticizing HTMX a lot. Although, in hindsight it was a good choice. It was a conscious choice and it came straight out of 20 years of running WordPress sites.

If you have read why we built Hatamoto you will know most of the pain with WordPress never came from the features. It came from everything bolted on around them. Plugins updating themselves at 2am, one plugin depending on another, a site you cannot upgrade because something somewhere is pinned to an old version. Nobody set out to build it that way, it just happened one dependency at a time over the years...

So when we started Hatamoto, I wanted to ensure that we kept it as simple and stupid as possible. Keep it fast, keep it simple, no build step and no dependencies or very low dependecies. One of the key decisions was that it should run on a $5 server with heaps of memory & CPU to spare.

We did look at Astro properly. I do not want to be unfair to it because it is very good at what it does. It ships no JavaScript to the browser unless you ask it to and the pages it produces are fast. If I was building a marketing site I would probably use it.

The problem is the speed is in the output. To get there you need Node, npm, a build step and a few hundred packages. For a static site you build it once and forget about it. A CMS is different - it runs on a customer's server, it has an admin and it has to update itself safely. That means a second runtime sat next to our Go binary that we have to ship, patch and keep happy forever.

React and the rest of them are built for apps where most of the work happens in the browser. A CMS admin is mostly forms, tables and lists, and the content lives in the database. Moving all of that into the browser means keeping two copies of the same data in sync, and writing an API just so our own front end can talk to our own back end.

So we went with HTML rendered on the server, and htmx for the bits that need to update without a full page reload.

For anyone who has not used it, htmx is one small file with no dependencies of its own. You add a few attributes to your HTML, it sends a request to the server and the server sends back a bit of HTML to swap in. That is more or less it.

Speed first. When someone visits a Hatamoto page they get HTML straight from memory. There is no bundle to download and no hydration step before the content shows up. That matters a lot more than people think for anyone on a cheap phone or a bad connection, and for Google and the AI crawlers reading the raw page. A page that works with JavaScript switched off works for pretty much everyone.

Simple second. The server is in charge of everything. When you save a post or change a setting, htmx sends the request and the server decides what the screen should look like. There is nothing in the browser to get out of sync with the database, which removes a whole class of bugs I have spent far too many hours chasing on other projects in wordpress. It also means one language - the same Go templates render the public site and the admin.

No build step is the one I think people underestimate the most. A build step is not just one command. It is a toolchain with its own versions and its own config, and it breaks on its own schedule. With Hatamoto, go build produces everything. The templates, the CSS and htmx itself are all embedded in the binary, so what we test is what ships. It matters for updates too - our signed updates with automatic rollback only have one file to check and roll back, not two built by different toolchains.

And dependencies. htmx is about 14KB. A fresh JavaScript project can pull in hundreds of packages before you have written anything, all written by people you have never met and updated whenever they feel like it. That is the WordPress plugin problem all over again. We went to the trouble of sandboxing plugins in WebAssembly - it would have been a bit silly to then let the same problem back in through npm install.

The server publishes the post and sends back the bit of HTML with the new status. No JSON API, no state library and no loading spinner code. If the JavaScript does not load for some reason the form still posts and the page reloads with the right status.

It is not all good news and I do not particularly claim it is the right choice for everyone. Very interactive things like drag and drop builders are harder this way, and where we need that we write a small bit of plain JavaScript for that one feature. There is no big library of ready made htmx components so we build more ourselves. Every click is a trip to the server - on a decent server nobody notices, on a bad connection you will. And more developers know React than htmx, although anyone who knows HTML picks it up in a day.

If you are building a design tool, a spreadsheet or something that has to work offline, use a framework. That is what they are for.

But most of the web is forms, lists and pages sitting on top of a database, and browsers have been very good at HTML for 30 years.

Hatamoto builds with one command, ships as one file and runs on a $5 server using about 90MB of memory. I would struggle to say the same if we had gone the other way.

The code is open source on hatamoto.dev if you want to tell me where I got it wrong.

Discussion

Leave a comment

(never shown)
Comments with links are reviewed before they appear.

0 comments

    Run it on your own server.

    Open source, one Go binary and Postgres. AI analytics start counting from the first request.

    curl -fsSL https://hatamoto.dev/install.sh | sudo sh