JavaScript can be inserted into a separate document and called when necessary.
This is known as an external JavaScript file.
You might recall we did this scene with our external C Ss file.
Let's take a javascript function in our previous lesson and inserted into a new file.
And when a copy of the entire function or sorry when it cut it I'm going to create a new file and paste
it.
Now I'm going to save this file as dog age J.S. J stands for JavaScript
now in the head take we need to call this script
and we'll do that by adding a source attribute to the script tag
now we'll save this file and I'll previewed in my browser just to make sure it works.
We can see that the script is working so we know that the javascript file was called successful
there's a couple of advantages to using external JavaScript files.
First it makes the HCM L code in JavaScript code easier to maintain cached JavaScript files.
Also increase the speed at which the web page loads.