Referencing external JavaScript files in HTML requires: creating a <script> tag; setting the src attribute to specify the path to the external JavaScript file; closing the <script> tag.
How to reference external JavaScript files using HTML
Referencing external JavaScript files in HTML requires three steps:
1. Create <script>
tag
<code class="html"><script></code>
2. Set src
attribute# The
##src attribute specifies the path to an external JavaScript file:
<code class="html"><script src="path/to/external_script.js"></script></code>
3. Close the <script> tag
<code class="html"></script></code>
Example:
The following code will reference an external JavaScript file namedexternal_script.js:
<code class="html"><script src="js/external_script.js"></script></code>
Best Practice:
tag to avoid page load delays.
The above is the detailed content of How to reference external js in html. For more information, please follow other related articles on the PHP Chinese website!