I have a page where the landing page has images that change in time (on by one the images change). That works fine, but when uploading the site, I realised that my images at the landing page load very slowly and therefore it does not look good. Once all loaded (all appeared at least once) then page is good again and the transitions smooth and nice.
I was thinkin of a way to preload the images. I found many stuff and tried the following:
$(window).load(function() {
$(".loader").fadeOut("slow"); /*gif that shows when page loads*/
function backgrounds() {
for (i = 0; i < preload.arguments.length; i++) {
images[i] = new Image()
images[i].src = preload.arguments[i]
}
}
})
var backgrounds = new Array(
'url(Images/image_1.jpg)'
, 'url(Images/image_2.jpg)'
);
$(document).ready(function(){
/*I have here other functions as well as the function that changes the images one by one*/
});
No success. When loading page first time I have the exact same problem. The photos the first time load extremely slowly and also the change function of the photos starts before they even have time to load (have way of the loading the function that rotates the pics comes in and makes a change).
As I am newbie to all this, could anyone please help with what is the best way to tackle the problem, and make sure that the loading is done first.
Many thanks