Since sprites / pagination were not an option in this situation, I found the following best solution:
Adaptation of the method of loading images by scrolling with some settings and cool adjustment of the parent element for each image (so that for each image there are 1000 elements, each with images).
If the parent elements default to display:none , and also do the first 25 display:block :
var scrollPos = 0; var endEle = 0;
$ (window) .scroll (function () {
scrollPos = $(window).scrollTop(); if ($(window).scrollTop() < scrollPos + 250) { //load 15 images. $('.myDiv img').slice(endEle,endEle+50).each(function(obj){ var self = $(this); var url = self.attr("role"); self.attr("src", url); self.parent().css("display","block"); }); endEle = endEle + 50; }
});
This sets the following 50 elements to display:block and switches the <img role> to <src> (the image URLs were placed in the role when rendering the page) each time the user scrolls 250 pixels.
sgb
source share