(Solved):What are the advantages of using an external JavaScript file? Explain.

 

Question

What are the advantages of using an external JavaScript file? Explain.

 

EXPERT ANSWER

Scripts can be inserted in internal HTML files as well as from external files. The name of the file is provided in the src attribute of the <script> tag if required.

For example, here a small piece of javascript code is written and saved as externalScript.js.

Code:

function myFunction() {
 alert("external script is

Scroll to top