I need to get the size of many small <div>
-Elements, before inserting them into the DOM.
Currently, I'm adding them temporarily, getting their offsetWidth
and offsetHeight
, then I remove them again:
document.body.appendChild(child);
size = [child.offsetWidth, child.offsetHeight]
document.body.removeChild(child);
The problem is, that this is super-slow, because it triggers a reflow for every <div>
being measured.
Do you have any idea how to speed this up?