javascript run on page ready code example
Example 1: dom ready js
document.addEventListener("DOMContentLoaded", function() {
// code
});
Example 2: wait for page load js
window.addEventListener('load', function () {
})
//THE OTHER ANSWER IS WRONG (has a syntax error)