This is really only following on from an answer to Flexslider lazyloading here I am using that code which I Have pasted below. I would like to alter it so that images only loaded when truly needed.
I tried the other Flexslider properties, before: and after: but they created a delay on the first slide? Please can I get some help with this.
$('#slider').flexslider({
start: function (slider) {
// lazy load
$(slider).find("img.lazy").each(function () {
var src = $(this).attr("data-src");
$(this).attr("src", src).removeAttr("data-src");
});
}
});
If you not only want lazy loading but preloading the following slides you should change the solution from Brownrice to
with this code the second slide will be preloaded during page load and every following slide will be preloaded when the previous slide is active.
I had a similar problem. My sollution is not perfect, but you could do something like this:
On start it loads the first image, the second and the last one. On before it loads the current image, the next and the previous one, so the next pictures are always preloaded. The variables currentSlide and count are provided by flexsliders callback API.
I got some help in the end, here we have less code :)
Jquery:
HTML: