frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

How to Build Reactive Declarative UI in Vanilla JavaScript

https://jsdev.space/howto/reactive-vanilla-js/
29•javatuts•4h ago

Comments

xutopia•2h ago
For the life of me I don’t understand why people absolutely insist on using JavaScript to render HTML. Backend frameworks do HTmL just fine.

DOM manipulations can be simplified to just a few actions: remove, Add, change.

The other types of manipulations and interactive features can be sprinkles of JavaScript instead of hundreds of kilobytes of the stuff.

HTMX, Hotwire/Turbo, LiveView are just so much saner to me.

intrasight•2h ago
Morphing the web user agent into something akin to an X11 server made total sense to me when I started doing such in 2000. If we developers had demanded a true distributed windows system, then we would have been spared this bag of hurt.

I remember demoing the Andrew Window Manager to colleagues in 1989 and them feeling like they had glimpsed the future. Alas, that future never came.

https://mirrors.nycbug.org/pub/The_Unix_Archive/Unix_Usenet/...

yoz-y•2h ago
For me the debate never reaches the end because different kinds of developers build fundamentally different kinds of products.

If you are building a website, a forum, or a generally document based application with little to no interactivity (beyond say, “play media”) then absolutely make a server rendered html page and sprinkle it with a bit of JavaScript for accordions.

If what you are building is a complex editor (image, text), is highly interactive (with maps, and charts and whatever) and users will generally spend a lot of time navigating between almost same pages. Basically when there would be no expectation that this should work with JavaScript disabled… then just build a purely client rendered application in the framework of your choice.

To me the dispute comes when one bleeds to another. I also think that mixed modes are abominations unless you truly have actual performance gains (maybe if you have 1B+ customers), which I’d argue is true for almost no one.

Zanfa•1h ago
> For the life of me I don’t understand why people absolutely insist on using JavaScript to render HTML. Backend frameworks do HTmL just fine.

There’s an entire universe of front-end developers who don’t even know JavaScript. React is the only thing they’ve ever touched and they’re completely helpless without it.

matharmin•2h ago
There are a bunch of utilities that don't actually _do_ anything useful. The proxy in this example is used for nothing other than debug logs. The DOM utility layer just slightly reduces the number of LOC to create a DOM node.

And then you end up with consumer code that is not actually declarative? The final code still directly manipulates the DOM. And this shows the simplest possible example - creating and removing nodes. The difficult part that libraries/frameworks solve is _updating_ the DOM at scale.

vntok•2h ago
This is a really weird website, I glanced over a bunch of different articles and all read like AI slop to me.

Indeed, a detecting tool like GPT Zero is "highly confident" that 97% of this article is AI generated, while AI Detector returns "We are 100% confident that the text scanned is AI-generated".

Curious if this is an uncanny valley situation, because there aren't that many tells (dashes, etc.) in the text itself. Does it feel the same to you?

KaiMagnus•2h ago
Didn’t look at it too closely, but the whole article as it stands is almost completely copy-pastable from a llm chat. Another comment pointing out that there’s some code that doesn’t do anything is another clue.

(Not saying it was, but if I’d ask the llm to create and annotate a HTML manipulation poc with code snippets, I’d get a very similar response.)

Edit: Pretty sure the account itself is only here to promote this page.

Mashimo•2h ago
> Edit: Pretty sure the account itself is only here to promote this page.

Dang, he submitted about 50 times that website to HN.

Can an admin please take a look?

efortis•2h ago
I'm experimenting with recreating the whole DOM tree like this:

  function render() {
    restoreFocus(() => 
      document.body.replaceChildren(App()))
  }

  function App() {
    return (
      createElement('div', { className: 'App' }, 
        createElement('h1', null, 'Hello, World')))
  }

  function createElement(tag, props, ...children) {
    const elem = document.createElement(tag)
    for (const [k, v] of Object.entries(props || {}))
           if (k === 'ref')        v.elem = elem
      else if (k === 'style')      Object.assign(elem.style, v)
      else if (k.startsWith('on')) elem.addEventListener(k.slice(2).toLowerCase(), ...[v].flat())
      else if (k in elem)          elem[k] = v
      else                         elem.setAttribute(k, v)
    elem.append(...children.flat().filter(Boolean))
    return elem
  }

`restoreFocus` is here:

https://github.com/ericfortis/mockaton/blob/main/src/client/...

Results so far:

Rendering the whole DOM tree (instead of VDOMs) is a fast process. The slow part is attaching (committing) elements to the doc. For example, I have a test of 20,000 elements which takes <30ms to render, while attaching them takes 120ms.

Since the performance is mainly bound to the commit phase, with a DOM merging library, or hopefully, if we get a native API such as `document.replaceChildren(...App(), { merge: true })`, this approach could be better.

Caveats:

Although it restores focus, that's not the only thing we need to preserve, we also need to preserve scroll position and cursor position.

So to work around that, I still have to step out fully declarative, by just replacing the part that changed. For example, here I had to do manually mutate the DOM:

https://github.com/ericfortis/mockaton/blob/main/src/client/...

my_throwaway23•1h ago
Looks an awful lot like https://github.com/jorgebucaran/hyperapp
efortis•1h ago
Both are based on the signature of React.createElement. JSX gets compiled to something like that.

https://react.dev/reference/react/createElement

my_throwaway23•1h ago
Have you heard of hyperapp? From the official [0][@hyperapp/html]:

    import { app } from "https://unpkg.com/hyperapp";
    import {
        main,
        h1,
        button,
        text,
    } from "https://unpkg.com/@hyperapp/html?module";

    const Subtract = (state) => ({ ...state, count: state.count - 1 });
    const Add = (state) => ({ ...state, count: state.count + 1 });

    const page = ({count}) =>
        main([
            h1(text(count)),
            button({ onclick: Subtract }, text("-")),
            button({ onclick: Add }, text("+")),
        ]);

    app({
        init: (count = 0) => ({ count }),
        view: page,
        node: document.getElementById("app"),
      })
I can't imagine building anything anymore with the overly verbose bloat that is React.

[0]: https://github.com/jorgebucaran/hyperapp/tree/main/packages/...

hu3•1h ago
this is great! and looks like https://mithril.js.org
dizlexic•1h ago
I ask a LLM to do it :'(
aziis98•1h ago
The real problem vdom and more complex frameworks solve for me is dealing with much more complex state i.e. lists.

When dealing with lists there are so many possible ways of updating them (full updates, insertion/removal at an index, update at an index, ...) that manually mounting and unmounting single items by hand gets unbearable. You must then do some kind of diffing at the framework level to get good performance and readable code.

I would like to see "VanillaJS" articles talk both more and more in depth about this problem.

Floppy disks turn out to be the greatest TV remote for kids

https://blog.smartere.dk/2026/01/floppy-disks-the-best-tv-remote-for-kids/
127•mchro•2h ago•51 comments

LLVM: The Bad Parts

https://www.npopov.com/2026/01/11/LLVM-The-bad-parts.html
32•vitaut•1h ago•0 comments

Why Ontario Digital Service couldn't procure '98% safe' LLMs (15M Canadians)

https://rosetta-labs-erb.github.io/authority-boundary-ledger/
21•csemple•36m ago•6 comments

The struggle of resizing windows on macOS Tahoe

https://noheger.at/blog/2026/01/11/the-struggle-of-resizing-windows-on-macos-tahoe/
2196•happosai•18h ago•916 comments

Reproducing DeepSeek's MHC: When Residual Connections Explode

https://taylorkolasinski.com/notes/mhc-reproduction/
30•taykolasinski•1h ago•8 comments

Launch a Debugging Terminal into GitHub Actions

https://blog.gripdev.xyz/2026/01/10/actions-terminal-on-failure-for-debugging/
61•martinpeck•3h ago•8 comments

Zen-C: Write like a high-level language, run like C

https://github.com/z-libs/Zen-C
50•simonpure•2h ago•39 comments

Lightpanda migrate DOM implementation to Zig

https://lightpanda.io/blog/posts/migrating-our-dom-to-zig
127•gearnode•5h ago•64 comments

Ai, Japanese chimpanzee who counted and painted dies at 49

https://www.bbc.com/news/articles/cj9r3zl2ywyo
88•reconnecting•6h ago•31 comments

Windows 8 Desktop Environment for Linux

https://github.com/er-bharat/Win8DE
105•edent•2h ago•99 comments

CLI agents make self-hosting on a home server easier and fun

https://fulghum.io/self-hosting
656•websku•18h ago•446 comments

Show HN: 30k IKEA items in flat text

https://huggingface.co/datasets/tsazan/ikea-us-commercetxt
34•tsazan•5d ago•26 comments

JRR Tolkien reads from The Hobbit for 30 Minutes (1952)

https://www.openculture.com/2026/01/j-r-r-tolkien-reads-from-the-hobbit-for-30-minutes-1952.html
204•bookofjoe•5d ago•71 comments

The Manchester Garbage Collector and purple-garden's runtime

https://xnacly.me/posts/2026/manchester-garbage-collector/
4•xnacly•4d ago•0 comments

Ireland fast tracks Bill to criminalise harmful voice or image misuse

https://www.irishtimes.com/ireland/2026/01/07/call-to-fast-track-bill-targeting-ai-deepfakes-and-...
44•mooreds•1h ago•14 comments

39c3: In-house electronics manufacturing from scratch: How hard can it be? [video]

https://media.ccc.de/v/39c3-in-house-electronics-manufacturing-from-scratch-how-hard-can-it-be
191•fried-gluttony•3d ago•86 comments

Ozempic reduced grocery spending by an average of 5.3% in the US

https://news.cornell.edu/stories/2025/12/ozempic-changing-foods-americans-buy
185•giuliomagnifico•3h ago•271 comments

Personal thoughts/notes from working on Zootopia 2

https://blog.yiningkarlli.com/2025/12/zootopia-2.html
84•pantalaimon•5d ago•1 comments

2025 marked a record-breaking year for Apple services

https://www.apple.com/newsroom/2026/01/2025-marked-a-record-breaking-year-for-apple-services/
7•soheilpro•1h ago•1 comments

iCloud Photos Downloader

https://github.com/icloud-photos-downloader/icloud_photos_downloader
558•reconnecting•20h ago•214 comments

This game is a single 13 KiB file that runs on Windows, Linux and in the Browser

https://iczelia.net/posts/snake-polyglot/
258•snoofydude•17h ago•67 comments

Keychron's Nape Pro turns your keyboard into a laptop‑style trackball rig

https://www.yankodesign.com/2026/01/08/keychrons-nape-pro-turns-your-mechanical-keyboard-into-a-l...
18•tortilla•43m ago•6 comments

Conbini Wars – Map of Japanese convenience store ratios

https://conbini.kikkia.dev/
99•zdw•5d ago•42 comments

XMPP and Metadata

https://blog.mathieui.net/xmpp-and-metadata.html
48•todsacerdoti•5d ago•11 comments

The next two years of software engineering

https://addyosmani.com/blog/next-two-years/
237•napolux•17h ago•235 comments

Climbing the mountain: or, venturing into PL theory

https://techne98.com/blog/climbing-the-mountain/
11•fixedprog•5d ago•0 comments

I'm making a game engine based on dynamic signed distance fields (SDFs) [video]

https://www.youtube.com/watch?v=il-TXbn5iMA
397•imagiro•4d ago•57 comments

Uncrossy

https://uncrossy.com/
139•dgacmu•13h ago•40 comments

FUSE is All You Need – Giving agents access to anything via filesystems

https://jakobemmerling.de/posts/fuse-is-all-you-need/
186•jakobem•18h ago•61 comments

Perfectly Replicating Coca Cola [video]

https://www.youtube.com/watch?v=TDkH3EbWTYc
285•HansVanEijsden•3d ago•186 comments