So i am reading the height of an element using .offsetHeight within a window.onload listener. This means that the html elements must have loaded. However, if i use the same code but instead of using the window.onload i use a setTimeout with a 100ms wait time, the offsetHeight is different (which appears to be the correct value). Why is this? I obviously don't want to be adding unnecessary load times onto my web pages, are there any work arounds?
P.s even when using a 50ms wait time the results are inconsistent.
Thanks in advance.