jQuery - Preload images
William McKeehan
William McKeehan
February 3, 2022

jQuery - Preload images

jQuery - Preload images

jQuery make it easy to preload images in the background so visitors won’t have to wait forever when they would like to display an image. This code is ready to use, just update the image list on line 8.

$.preloadImages = function() {
  for(var i = 0; i<arguments.length; i++) {
    $("<img />").attr("src", arguments[i]);
  }
}
$(document).ready(function() {
    $.preloadImages("hoverimage1.jpg","hoverimage2.jpg");
});

Source: [http://css-tricks.com/snippets/jquery/image-preloader/