page ready javascript code example
Example 1: document ready jquery
$(function() {
// Handler for .ready() called.
});
Example 2: js on page ready
document.addEventListener("DOMContentLoaded", function(event){
// your code here
});
Better than
window.onload = function(){
// code goes here
};
Example 3: ondocumentready
// A $( document ).ready() block.
$( document ).ready(function() {
console.log( "ready!" );
});