In HTML, you can embed JavaScript in a web page, in an external JavaScript file, or both. The following shows how to link external JavaScript files (file extensions ending in .js) to a web page.
1. External JavaScript file
Create a new file with a ".js" file extension and put the JavaScript code in in. That’s it, you just created an external JavaScript file