Notes
- the file extension for JavaScript
files is .js
- files are added to HTML pages using the
<script>
tag with the src
property in the header of the HTML page.
- Why use external code files?
- they can be applied to multiple
HMTL pages with the addition of just 1 line of
code
- HTML and JS pages can be edited
side by side--no more scrolling!
- Removing the JS code from HTML pages
streamlines the HTML, reduces the file size, and
improves accessibility.
Definitions
- external code files
- stand-alone files that can be linked
to HTML pages
Example
A JavaScript code file with the name
"maincode.js" that's located in a js sub-
folder would be connected to this page
with a line of code like this:'
<script src="js/maincode.js"></script>