DOMContentLoaded vs local script
What is the difference between a script called by DOMContentLoaded event handler and a script called at the end of the body ?
- Obviously, they execute in slightly different context - the inline script is "top-level" code, the DOMContentLoaded handler is in an event listener function.
- Perhaps also obviously, DOMContentLoaded is executed some time after the last inline script. See HTML5 specification for the list of steps supposed to happen in between.