Scripts without async , defer or type="module" attributes, as well as inline scripts, are fetched and executed immediately, before the browser continues to parse the page.

To get the offsetHeight when using an inline script you can use an event listener like

window.addEventListener(‘load’, start);

load to wait for all assets OR link the script with ‘src’

<script src=”app.js”></script>

to load it after the assets loaded.