JavaScript in HTML
Matt Frisbie · 2019
The introduction of JavaScript into web pages immediately ran into the web 's predominant language, HTML. The HTML5 specification indicates that scripts will be executed in the order in which they appear, so the first deferred script executes before the second deferred script, and both will execute before the DOMContentLoaded event. HTML5 introduces the async attribute for elements. The rules for writing code in XHTML are stricter than those for HTML, which affects the element when using embedded JavaScript code. The syntax to include external files is the same for both HTML and XHTML. Although it's possible to embed JavaScript in HTML files directly, it's generally considered a best practice to include as much JavaScript as possible using external files. Since Internet Explorer first introduced the concept of document modes, other browsers have followed suit. The element was created to provide alternate content for browsers without JavaScript.