views:

14

answers:

1

I can't test this live at the moment, so I'm asking:
If this script is busy loading images from an array (say, a few MB worth), and the user happens to perform some behavior that requires one of the images that has not yet loaded, will its loading be delayed? Or can the browser send out parallel requests?

function preloadImg()
{ 
var args = simplePreload.arguments;
document.imageArray = new Array(args.length);
for(var i=0; i<args.length; i++)
  {
  document.imageArray[i] = new Image;
  document.imageArray[i].src = args[i];
  }
}
+1  A: 

Browsers will only run so many requests in parallel on the same domain. The number varies between browsers. So you would typically expect to see additional requests get queued at the end.

One way to get around this to some extent is to have your preload images on a different domain than the other images since browsers will to load requests from different domains in parallel.

So if you are preloading 8 images in parallel maximum from domaina.com you could still have the images that might be needed on command on domainb.com loading at the same time. That could help you with the parallel loading issues.

I imagine you will still want to test your particular issues out in a few browsers, but I hope this will be helpful.

jarrett