As you probably know, the tag is used to specify which JavaScript to execute on a web page. The <script> tag can contain JavaScript code directly or point to a JavaScript external URL. </p> <h3 id="script-"><script>The tags are executed in the order in which they appear</h3> <p>The following code illustrates this intuitively:</p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false;"><script> var x = 3; alert(x); // Will alert '3'; Copy after loginThere is no loading order when using external link resources So intuitive, but still true: Copy after loginRelated learning recommendations: javascript video tutorialIf you mix external links and inline links For JavaScript, the same rule applies. This means that if your website has slow scripts that are loaded earlier in the page, your page loading will be significantly slower. This also means that scripts loaded later can depend on scripts loaded earlier. The page element will not be rendered until all scripts before it have been loaded. This means that you can do all kinds of crazy things on your web pages before they load, as long as you don't care about the performance issues this causes. However, this rule does not apply to you adding tags to the DOM through methods such as <code>document.appendChild</code> after the web page is loaded. These tags will execute the scripts in the order in which the browser request processing is completed, and the loading order is no longer guaranteed. </p><h3 id="-script-html-">When a <script> tag is executed, the HTML elements before it are accessible (but those after it are not yet available) </h3><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false;"><html> <head> <script> // document.head is available // document.body is not! // document.head is available // document.body is available