Favorites

DOM Window: load event

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Window: load event
DOM Window EventThis event is supported by all modern browsers.
Updated 28th November 2026

The window's load event fires when the whole page has loaded, including images, style sheets and iframes.

Description

The load event fires on the window when the whole page has loaded, including all dependent resources such as images, style sheets and iframes. It comes after DOMContentLoaded. Use it when your code needs the final layout or image sizes; for most set-up code, DOMContentLoaded runs sooner. Individual images and scripts also fire their own load events.

If you add a load listener after the page has already finished loading, it never runs, so check document.readyState === 'complete' first in code that might load late. Slow images or third-party resources delay this event, so avoid waiting for it for anything users need straight away.

Listeners for window events are added with window.addEventListener(). The older way, assigning a function to a property such as window.onresize, only allows one handler, so a second assignment replaces the first.

Syntax

window.addEventListener('load', handler)

Example

<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='40'%3E%3Crect width='120' height='40' fill='%2393c5fd'/%3E%3C/svg%3E" alt="Blue rectangle">
window.addEventListener('load', () => {
  console.log('Everything loaded. Image width:', document.querySelector('img').naturalWidth);
});
document.addEventListener('DOMContentLoaded', () => console.log('DOM ready first'));

Browser Support

The following information will show you the current browser support for the Window: load event event. Hover over a browser icon to see the version that first introduced support for this event.

This event is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee