Easy learning with example program codes

External JavaScript file

The src attribute of script tag is used to add or include external JavaScript file into any number of html files. It increases the code re usability.


<script type="text/javascript" src="external.js"></script>

First create a JavaScript file and then save the file with .js extension. After that we can use src attribute of script tag to use this already created file.


function show() {
   alert("External JavaScript file.");
      <input type="button" value="Show" onclick="show()"/>
      <script src="test.js"></script>

Related topics:

Please follow and like us:

Copyright © 2020 CodesJava Protection Status