|
|
Log in / Subscribe / Register

String based HTML building

String based HTML building

Posted May 10, 2026 4:30 UTC (Sun) by khim (subscriber, #9252)
In reply to: String based HTML building by pabs
Parent article: Forgejo "carrot disclosure" raises security questions

> Probably the JavaScript ecosystem needs to deprecate and remove string based HTML building methods altogether.

And replace it… with what exactly?

> DOM based HTML building (document.createElement and friends)

Are entirely unsuitable for responsible interface. Because browsers don't have analogue of WM_SETREDRAW.

In an ideal world something like this would have been added decades ago… but in our world we have browsers with support for USB controllers and Bluetooth… but without sensible way of doing responsive UI except via crazy hacks.


to post comments

String based HTML building

Posted May 10, 2026 6:36 UTC (Sun) by kleptog (subscriber, #1183) [Link]

While string based HTML creation is probably required under the hood, I thought the same until someone introduced me to Vue.js. As a developer it allows you to decompose your UI into components with interfaces, and you have straightforward templating for the output. All your escaping issues vanish and suddenly I could reason about a JS application without going crazy.

This is hardly new technology. If this project is still creating HTML by string concatenation in 2026, then it does make me concerned for the state of the rest of the project. Even Django with its templating engine is 17 years old now.

String based HTML building

Posted May 10, 2026 6:58 UTC (Sun) by cladisch (✭ supporter ✭, #50193) [Link] (1 responses)

> > DOM based HTML building (document.createElement and friends)
>
> Are entirely unsuitable for responsible interface. Because browsers don't have analogue of WM_SETREDRAW.

By now, browsers have the View Transition API: https://developer.chrome.com/docs/web-platform/view-trans...

(Most of the documentation talks about animations; what matters is that all DOM changes are put into a single animation.)

String based HTML building

Posted May 11, 2026 14:57 UTC (Mon) by khim (subscriber, #9252) [Link]

Nice. So something that should have been available since the day one was added, after quarter century.

But it takes time to change the codebase. Three years is not enough to switch everything to a new API after quarter century of kludges.

String based HTML building

Posted May 11, 2026 3:50 UTC (Mon) by pabs (subscriber, #43278) [Link] (1 responses)

You are building DOM elements either way, string vs API seems orthogonal to responsiveness. Make some new DOM elements (with strings or APIs), replace the existing DOM elements. With API based DOM element building, you still do the page updates in the same way.

String based HTML building

Posted May 11, 2026 15:14 UTC (Mon) by khim (subscriber, #9252) [Link]

> You are building DOM elements either way

Yes. But compiting resources matter.

> string vs API seems orthogonal to responsiveness.

Only when you can stop automatic updates of the screen. If you couldn't (and for decades it was impossible) then it's Ω(N²) vs Ω(N).

> Make some new DOM elements (with strings or APIs), replace the existing DOM elements.

That may work, sure — but at this point you are no longer dealing with DOM, anyway, you are using DOM as canvas… may as well pick API that makes things marginally better (things like Vue.js).

You couldn't have safety and speed in the pre View Transition API web, and picking safety when your app is unusable is not something people like.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds