I need to accurately measure the dimensions of text within my web app, which I am achieving by creating an element (with relevant CSS classes), setting its innerHTML
then adding it to the container using appendChild
.
After doing this, there is a wait before the element has been rendered and its offsetWidth
can be read to find out how wide the text is.
Currently, I'm using setTimeout(processText, 100)
to wait until the render is complete.
Is there any callback I can listen to, or a more reliable way of telling when an element I have created has been rendered?