How to implement $(document).ready functionality without using jQuery?

Simply use the DOMContentLoaded event which fires when the DOM is loaded, but before all page assets are loaded (styles, images, etc.).

document.addEventListener("DOMContentLoaded", function(event) { 
  // do something
<!doctype html>
      <title>DOMContentLoaded Example</title>
    	var DOMContentLoaded = function(a,b,c){b=document,c='addEventListener';b[c]?b[c] ('DOMContentLoaded',a):window.attachEvent('onload',a)}
      DOMContentLoaded(function () {
        console.log('The DOM is Ready!');
  	<h1>DOMContentLoaded Example</h1>
  	<p>Super small Cross-browser DOM ready function</p>
add comment
Suggest a different solution or add another example