0

At the minute I have a button which is allowing me to display more images when you press "show more" button:

$(function(){
    $("#gallery li").slice(0, 10).show();
    $("#loadMore").click(function(e){
        e.preventDefault();
        $("#gallery li:hidden").slice(0, 10).show();
        if($("#gallery li:hidden").length == 0){
            alert("No more images");
        }
    });
});

it's working fine, however all the images are loaded when you first enter the website. I'm wondering if there is a way of not preloading all images, but only 10 displayed and when someone press on "show more" that's when more images will actually be loaded not shown ?

Thanks

TaZz
  • 652
  • 7
  • 20
  • 1
    Or another option would be to pre cache the images, this will not effect the loading time of the page but speed up displaying the images once you click on the "show more" button, kind of a best of both worlds approach. – Adam Buchanan Smith May 25 '16 at 20:30
  • Possible duplicate of [Load more on clicking without loading all images first](https://stackoverflow.com/questions/23643150/load-more-on-clicking-without-loading-all-images-first) – Kaiser Mar 27 '19 at 20:03

0 Answers0