The benefits of using an external style sheet include:
- Simplifies Maintenance
- Website Speed
Copy the section “alert(‘Hello World’);” out of the web page and paste it into the new text document you created and save it with a .js extension. In this case alert.js. It needs to be accessible to the web page that needs it so you could place it on the same folder or in a sub folder.
The src attribute in the script tag tells the page where it should look for the alert.js file. If you placed it in a sub folder you would change it to src=”folder/alert.js”. If you have problems with the script not working, check your path first to make sure you are loading the file.