Div position absolute in main css block?

Does it make sense to put

div {
position: absolute

in the main css section ?

The argument against this – I have not seen this described anywhere.

The argument for this is:

If we are using jsoo, it does not matter if we are using bonsai or react, we are updating the dom.

This causes reflows.

Reflows are expensive.

We want minimum # of reflows.

Thus, let’s have everything default to div position absolute, and manually specify the elements we want to be reflow-ed.

I’m not sure if this is the right way to do things; or if I am missing something really obvious.


Have you found this issue to be a performance bottleneck for your application? I don’t know exactly what you’re building, but my gut feeling is that this might be premature optimization.

1 Like

Good point. I do not have benchmarks to back any of this up; this is pure speculation.

I’m building a 3d visualization app in OCaml / Rust, with the “GUI” side in OCaml / Bonsai.

You’re kind of giving up the advantages of css, IMO. In a world without a layout engine you’d have to specify where everything is ala position absolute, and eventually you’d build abstractions on top of it to be able to express ideas that css gives you for free - e.g. this header has five elements that I want equally sized and spaced.

Somewhat related: This is a blog post by someone who wrote an iphone game in html - they rendered the game portion itself in canvas but all the UI around it in regular html. I think that combination can work well

1 Like

Yeah, upon further reflection, I think this is a bad idea on my part.