How to execute a function when page has fully loaded?

javascript

Solution

That's called `load`. It came waaaaay before DOM ready was around, and DOM ready was actually created for the exact reason that `load` waited on images.

window.addEventListener('load', function () {
  alert("It's loaded!")
})

Problem

I need to execute some JavaScript code when the page has fully loaded. This includes things like images. I know you can check if the DOM is ready, but I don’t know if this is the same as when the page is fully loaded.

Original source

Related problems