JavaScript: Inline Script with SRC Attribute JavaScript inline scripts are commonly included using the tag with a src attribute to load an external script file. However, can inline scripts be defined within the same <script> tag?</p> <p>According to the HTML 4.01 Specification, the behavior of a <script> tag with both an inline script and a The src attribute is explicit: </p> <blockquote>If the src attribute is not set, user agents MUST interpret the element's content as script. If src has a URI value, the user agent MUST ignore the element's contents and retrieve the script via the URI. </blockquote> <p>This means that the src attribute in the <script> tag has priority and inline scripts will be ignored. That said, the following is valid JavaScript usage: </p> <pre><code class="html"><script type='text/javascript' src='/path/to/script.js'> Load external scripts into the page without executing any inline scripts. However, the following usage is incorrect: alert('Do some stuff here, using resources defined in script.js.'); In this example, the inline script will be ignored because the src attribute is present. To execute an inline script, the src attribute must be omitted: alert('Do some stuff here, using resources defined in script.js.');