Inline Script with SRC Attribute in JavaScript In JavaScript programming, we typically include an external script file using the tag with a src attribute. However, a question arises whether it's possible to have an inline script with a src attribute, similar to the following:</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre><code class="html"><script type='text/javascript' src='/path/to/script.js'> alert('Do some stuff here, using resources defined in script.js.'); Copy after login Official Behavior According to the HTML 4.01 Specification, the src attribute of the tag takes precedence over the body of the tag. This means that if both an external script file and an inline script are present, only the external script will be executed.</p> <p>The specification states:</p> <blockquote>"If the src attribute is not set, user agents must interpret the contents of the element as the script. If the src has a URI value, user agents must ignore the element's contents and retrieve the script via the URI."</blockquote> <p><strong>Conclusion</strong></p> <p>Therefore, it's not possible to have both an inline script and a src attribute in the same <script> tag. Only one of them will be executed, and the src attribute will have higher priority.</p>