if page is loaded javascript code example
Example 1: js on page loaded
window.onload = function() {
yourFunction(param1, param2);
};
Example 2: how to check if page is loaded in javascript
<body onload="onload()">
<div>
<p>TEXT</p>
</div>
</body>
<script>
function onload(){
console.log("Window Has Been Loaded!")
}
</script>
Example 3: wait for page load js
window.addEventListener('load', function () {
})
//THE OTHER ANSWER IS WRONG (has a syntax error)