I have a JSON file referencing about 300 images used in an animation displayed within my Wordpress theme. In my header.php, I'm using the following jQuery to preload all images on DOM load.
function preload(images) {
jQuery(images).each(function () {
jQuery('<img />').attr('src',this).appendTo('body').css('display','none');
});
}
jQuery(document).ready(function() {
preload([
"<?php bloginfo('template_directory'); ?>/library/images/img001.jpg",
"<?php bloginfo('template_directory'); ?>/library/images/img002.jpg",
//about 300 more...
]);
});
The issue is the images are 900x400px so it takes about 30 seconds for all 300 HTTP requests to go through. I'm thinking I could decrease load time if I load images with just one HTTP request. Is this possible? Thanks in advance.