I have an index.html file which includes a javascript file. Javascript file has a document.onload function which never gets executed. Can someone tell me why is this not being executed when DOM is loaded.
console.log("javascript file started loading");
document.onload = function () {
console.log("document loaded");
alert("DOM is ready");
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script src="app.js"></script>
<h1>cool page onload</h1>
</body>
</html>