JavaScript warten Sie, bis das Bild geladen wird

<!-- new Image(); -->
<script>
	const image = new Image();
	// make sure onload is set before src is set
	image.onload = function() {
		console.log("Image loaded:", image.src);
	};
	image.src = "image url";
</script>
<!-- <img> -->
<img id="img" src="image url"></img>
<script>
	const img = document.getElementById("img");
	img.onload = function() {
		 console.log("Image loaded:", img.src);
	};
</script>
MattDESTROYER