This is a kind of hack, but it may work for you, the slider plugin supports the before and after functions, which we can use to postpone downloading images for you.
taking into account the following markup:
<div id="s1" class="pics">
<img src="http://cloud.github.com/downloads/malsup/cycle/beach1.jpg" width="200" height="200" />
<img src="http://cloud.github.com/downloads/malsup/cycle/beach2.jpg" width="200" height="200" />
<img asrc="http://cloud.github.com/downloads/malsup/cycle/beach3.jpg" width="200" height="200" />
<img asrc="http://cloud.github.com/downloads/malsup/cycle/beach4.jpg" width="200" height="200" />
<img asrc="http://cloud.github.com/downloads/malsup/cycle/beach5.jpg" width="200" height="200" />
<img asrc="http://cloud.github.com/downloads/malsup/cycle/beach6.jpg" width="200" height="200" />
<img asrc="http://cloud.github.com/downloads/malsup/cycle/beach7.jpg" width="200" height="200" />
<img asrc="http://cloud.github.com/downloads/malsup/cycle/beach8.jpg" width="200" height="200" />
</div>
Note that the first two have a valid src attr, and the rest have asrc, which does not load through the browser.
Now, using the before and after function, we can take advantage of this and switch asrc to the real src, which will cause the browser to request an image.
$('#s1').cycle({
fx: 'shuffle',
speed: 'fast',
timeout: 0,
next: '#next2',
prev: '#prev2',
before: function(currSlideElement, nextSlideElement, options, forwardFlag) {
if ($(nextSlideElement).attr("asrc")) {
$(nextSlideElement).attr("src", $(nextSlideElement).attr("asrc"));
}
},
after: function(currSlideElement, nextSlideElement, options, forwardFlag) {
if ($(nextSlideElement).attr("asrc")) {
$(nextSlideElement).attr("src", $(nextSlideElement).attr("asrc"));
}
}
});
An example of this is on jsfiddle .
source
share