I'm a bit confused about your recommendation about using the inline script. I
actually would have preferred to do it that way (inline), but a more experienced
frontend dev told me that there is no guarantee that the browser will have
rendered the element ('my-widget' in your example) before executing the script,
even though the script follows the 'my-widget' element in DOM order.
Can you clarify on this point?
jon
The DOM node is there and if you query for its size or something else
that requires a reflow a reflow will happen so that the layout data is
up to date.
The only argument against doing the inline code is that it makes it
harder to maintain because you have all these inline scripts
intermixed with your content.
--
erik
jon
The only argument against doing the inline code is that it makes it
harder to maintain because you have all these inline scripts
intermixed with your content.
I remember having read somewhere that inline scripts are not recommended, because the browser may be blocked from doing a bunch of stuff in parallel, on the off chance that your script might be calling document.write().