- This is also called "External JavaScript"
<!DOCTYPE html>
<html>
<head><title>Script Tag Example</title>
<script src="myjavaFile.js"></script>
</head>
<body>
<button onclick="alertFun();">Click On Me</button>
</body>
</html>
"myjavaFile.js" file contains
function alertFun() {
alert('This is a External function alert message');
}
Output:

- you can create your java file externally and call it on your web page