External JavaScript part 3

External JavaScript
30
3/3













External JavaScript
The result of the previous example will be identical to the result when we included the JavaScript within the HTML file.
You can place an external script reference in <head> or <body>, whichever you prefer.
The script will behave as if it were located exactly where the <script> tag is located.
Placing a JavaScript in an external file has the following advantages:
- It separates HTML and code.
- It makes HTML and JavaScript easier to read and maintain.
- Cached JavaScript files can speed up page loads.
Please add the corresponding keywords to add the external sample.js file to the web page.
<
Script
type
="text/javascript"
Src
="sample.js"></script>
script
src
Comments
Post a Comment