Like most things in javascript canvas drawImage
method is synchronous. It means it won't execute the code any furhter until it gets its job done. Your images are indeed loaded one by one but it is so fast you can't see it.
To add a delay to the images loading we can make some kind of a queue. We'll add the images to the array and execute a drawing function after some amount of time:
img.onload = function() {
images.push(img);
};
(...)
var i = 0;
var images = [];
var timeoutFn;
(function draw() {
if (images.length) {
drawImage(images[0],0,0,500,500);
images.shift();
}
timeoutFn = setTimeout(draw, 1000);
})();
Now you'll need to set timeoutFn = null
once all the images are loaded. I hope you get the idea.