jargon

Frontend & browser·Rendering and the browser pipeline

your script ran before the images finished, because it only waited for the markup to be parsed.

DOMContentLoaded

Also calledDCL, document ready

The event fired when the HTML has been fully parsed and deferred scripts have run, without waiting for stylesheets, images or subframes. It is the one to use for anything that needs the DOM to exist; `load` waits for every subresource and can be seconds later on an image-heavy page. Neither is a good proxy for 'the page is ready for the user', which is what the Core Web Vitals metrics exist to measure instead.

Commonly confused with