I have a slideshow on every page that contains images of the object the page is about. Each slideshow usually contains 5-6 image slides.
What I'm thinking is to only set the src
attribute on the first 2 images, and on the rest I only set data-src
attribute to the image file, and then I load the rest of the images after the whole page has been loaded with the help of this Javascript:
function loadImages() {
$('#house-carousel .item img').each(function(){
if($(this).attr('data-src')){
$(this).attr('src', $(this).attr('data-src'));
}
});
}
$(document).ready(loadImages);
The thought process was that since the images are not displayed to the user for the first seconds of viewing the page, I can delay loading them and let the client download the rest of the content on the page first.
But now I'm thinking again... Does that really help? I mean, images are not render blocking; right? So does it really matter if I load them while the page is loading, or if I load them after the page has loaded?
Notice, it's not a script that "delays until the user views the image", it just delays it until the other resources has loaded first.
So what do you think? Does this really help or not? Speedtests such as http://tools.pingdom.com doesnt show any difference.