Inline Script with SRC Attribute in JavaScript In JavaScript, scripts are typically included using the tag, where the src attribute specifies an external script file. However, it's sometimes wondered if it's possible to combine an inline script with a src attribute.</p> <p><strong>The Rule</strong></p> <p>The official behavior is governed by the HTML 4.01 Specification, which states that the src attribute has precedence over the body of the <script> tag. This means that if a src attribute is present, the contents of the element are ignored, and the script is retrieved from the specified URI.</p> <p><strong>Example</strong></p> <p>Therefore, the following script will only run the code in the external file /path/to/script.js, ignoring the inline alert statement:</p> <pre><script type='text/javascript' src='/path/to/script.js'> alert('Do some stuff here, using resources defined in script.js.'); Conclusion It's important to note that inline scripts and external scripts serve different purposes and should not be mixed. Inline scripts are useful for small, self-contained tasks that don't require accessing external resources. External scripts are better suited for larger, more complex scripts that can be reused across multiple pages.