Skip to content(if available)orjump to list(if available)

HTML-in-Canvas

HTML-in-Canvas

18 comments

·August 2, 2025

BobbyTables2

I suppose all we need to do now is to compile a browser into WASM and run that browser inside a canvas element of the main browser…

SeanAnderson

I read the title and said "shut the fuck up, don't do that." but then I read the rationale and it's fair. It's true there is no layout engine inside canvas, and that is a pain, but I'm not sure it's such a pain as to invite this recursive hell.

nine_k

One of the more senior engineers I worked with told me: "Every real-life data structure I encountered was tree-like".

It would be easiest to just ask the browser to render a fragment of HTML onto a canvas, or onto some invisible bitmap, like you can with most other UI toolkits.

mook

Yeah, that's already available in Firefox for chrome/extensions, but not allowed for the web due to fingerprinting and other security risks. For example, rendering an iframe of your bank account…

https://searchfox.org/mozilla-central/rev/f691af5143ebd97034...

monster_truck

They would never do this because of fingerprinting, which is already the cause of most of the reasons we cannot 'just' do a lot of things, unfortunately.

E: And the infamous other half: malware. A bit over a decade ago malware devs started using canvas to do things like hide fragments inside of bitmap data in seemingly harmless ads and then a second script would extract and assemble it to evade detection.

teaearlgraycold

You could disallow recursion.

ttoinou

Soon we’re gonna need Canvas rendering inside of HTML-in-Canvas

bastawhiz

It should already work if the nested canvas uses the same approach. It's not cyclic, though. To make cyclic canvases work, you need to manually draw the parent canvas to a nested canvas.

codelikeawolf

I immediately got "Pimp My Ride" vibes. Yo dawg, I heard you like HTML so I put HTML inside the canvas inside the HTML.

hyperhello

I see reliable rich text editing as more of a priority.

turnsout

Sad to say, but the first thing I thought was "oh good, a new fingerprinting target."

tantalor

Waterluvian

45kb gzipped is pretty beefy but incredibly small when you consider just what it takes to make this work today. If I understand correctly, it’s basically a DOM and CSS renderer.

kizer

There's a bunch of CSS, etc. not supported by that. It would be great to have access to a native API to get bitmaps of the DOM.

masswerk

Well, a fingerprinting dream…

Meaning, no way, just for the security aspect.

deadbabe

true horror is finding every element of the HTML page your on has been rendered in a Canvas