1//two ways of executing JS code after page is loaded, use "DOMContentLoaded" when able
2
3document.addEventListener("DOMContentLoaded", function(){
4 //dom is fully loaded, but maybe waiting on images & css files
5});
6
7window.addEventListener("load", function(){
8 //everything is fully loaded, don't use me if you can use DOMContentLoaded
9});
1// A document ready block with JQery.
2$( document ).ready(function() {
3 // we ready for fire action with JQery.
4});
5
6
7// A document ready block with javascript.
8document.addEventListener("DOMContentLoaded", function(event) {
9 // we ready for fire action with javascript.
10});
1// A jQuery( document ).ready() block.
2jQuery( document ).ready(function() {
3 console.log( "ready!" );
4});
1document.addEventListener("DOMContentLoaded", function(event) {
2 //we ready baby
3});