I know PHP, server-side scripts, run first and output the html to the browser, then javascript is executed. However, I am trying to get a feel for how the javascript is executed and can’t quite figure it out.
Is Javascript executed top-down and is consistent with this top-down execution? I am dynamically creating javascript in PHP which is triggered by events in my webpage’s original javascript.
Will created JS execute exactly where I put it or will it fire before? after?
Thanks
JavaScript is executed by the clients browser and is parsed in conjunction with the
HTMLandCSS, whichever comes first.Yes
JavaScript inserted into the DOM will be parsed/executed immediately.