Skip to content

Instantly share code, notes, and snippets.

@zanona
Created March 6, 2015 12:05
Show Gist options
  • Save zanona/d46a76c28d2abfccee1a to your computer and use it in GitHub Desktop.
Save zanona/d46a76c28d2abfccee1a to your computer and use it in GitHub Desktop.
DOM Loading event triggering and ready state order

DOM Loading event triggering and ready state order

On document

(head or body have same behaviour)

  • inline/src
    • runtime - loading
    • onreadystatechange - interactive
    • DOMContentLoaded - interactive
    • onreadystatechange - complete
    • onload - complete
    • rAF - complete
  • async
    • runtime - interactive
    • onreadystatechange - complete
    • onload - complete
    • rAF - interactive / complete on slow connection (not reliable)
  • defer
    • runtime - interactive
    • DOMContentLoaded - interactive
    • onreadystatechange - complete
    • onload - complete
    • rAF - complete

Dynamic Injection

  • src/async/defer
    • runtime - interactive
    • onreadystatechange - complete
    • onload - complete
    • rAF - interactive / complete on slow connection (not reliable)
  • inline
    • runtime - interactive
    • DOMContentLoaded - interactive
    • onload - complete
    • rAF - complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment