document.addEventListener("DOMContentLoaded", function(event) { //do work }); // or window.onload = function() { };