External JavaScript file

The software developer can easily create an external JavaScript file and this script can be embedded into the html page.

This external file provides the facility of code re-usability because the single JavaScript file can be easily used in various html pages. Whenever you are making an external JavaScript then make sure that the file is saved in .js extension.

The experts have recommended embedding all the JavaScript files into one single file. When all the files are embedded in one file the speed of the web page increases.



function msg(){
 alert("Hi javascript tutorial for beginners");


<script type="text/javascript" src="js/alert.js"></script>
<p>Welcome to JavaScript</p>
<input type="button" value="click" onclick="msg()"/>

Javascript Interview Questions and Answers
  • What is the full meaning of SRC?
  • What is a javascript file?

Next ConceptJavaScript Comment