Hacker News new | ask | show | jobs
by youngtaff 1879 days ago
Be really interesting to understand when this actually get's executed

  <script type="module">
    document.documentElement.classList.remove('no-js');
    document.documentElement.classList.add('js');
  </script>
module has defer semantics by default i.e. it gets executed after the document has finished parsed, and I can't find anything in the WHATWG spec to suggest it's different for inline scripts

Maybe inline scripts ignore module, as they do defer and async

1 comments

Inline <script type="module"> is executed after DOMContentLoaded.

Inline <script> is executed during parsing.

https://html.spec.whatwg.org/multipage/scripting.html#the-sc... gives the full details of the interactions between type, src, defer and async. Inline scripts are normally referred to as script elements where the src attribute is not present.

Wow, thanks for that detail. That's some obscura to me.