Over a million developers have joined DZone.

Check If All The Images Have Been Loaded

DZone's Guide to

Check If All The Images Have Been Loaded

Free Resource
function allImagesLoaded
This checks if all the images have been loaded on the page
Returns 1 if all are loaded and 0 if they are not
The great thing is that it works on images that you dynamicaly add with javascript (common for ads, tracking and other 3 party solutions)

	// allImagesLoaded()
	// Checks if all the images are loaded in the document
	// It Does this by looping through all the images and checks the attribute .complete
	// If .complete is false then we set the return variable to 0
	function allImagesLoaded() {
		// return variable
		var imagesloaded = 1;
		// All images are saved in an array called document.images. Very usefull
		var images = document.images;
		// Loop through all the images
		for (var i = 0;i

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}