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.
  • DOMContentLoaded is useful in cases when you don't control the markup, e.g. library code or something like browser extensions (See also Unobtrusive JavaScript)

Need Your Help

Jcarousel initialization in wordpress

javascript jquery wordpress jcarousel

I try to implement jcarousel gallery in this dummy article