Import Javascript code from external file in HTML

If your Javascript code is too big, or just for readability and management purpose, it’s best to include Javascript codes from an external file. This method is also good for re-usability purpose.

The code below will load the Javascript code stored in myscript.js to the calling file.

<script language="JavaScript" type="text/javascript" src="myscript.js">

Sign up for The Complete JavaScript Course: Build Real Projects! and many other great courses on Udemy to learn more.

Written by Mohd Shakir Zakaria. Last updated on 2019-02-12