I have a bunch of images that I am preloading inside of a loop. One of
these images is also loaded by the html, so I get a good look at how
these two different methods perform. For measurement, I am using the
Network pane of the Safari Web Inspector, after clearing the cache.
The ClownFish image is 280KB, and when referenced by the HTML takes 14ms to
load, while the Aurora image referenced by JS in the preload is
116KB and takes 77ms to load.
var images = ['Aurora', 'ClownFish', 'DewDrop', 'EarthHorizon', 'FlowingRock', 'GentleRapids', 'GoldenPalace'];
images.each(function(elm){
var path = elm + '.jpg';
var preload = new Image();
preload.setAttribute('src',path);
});
Is this all overhead from setting up the Image() and then assigning
the src to it? Is there any way to speed this up?