Hi there,

It is my goal to defer loading of images in the cycle plugin. Which I
have accomplished as follows. But please have a look at the 4th line:
        $(
            function() {
                var imgStack = [];
                $('.slideshow > img:gt(2)').remove().each(function()
{ imgStack.push($(this).attr("src")) }).removeAttr("src");
                $('.slideshow').cycle({
                    fx: 'fade',
                    before: function(curr, next, opts) {
                                if (opts.addSlide) {
                                    if (opts.imgs.length) {
                                        var slide = new Image();
                                        slide.src = opts.imgs.pop();
                                        opts.addSlide(slide);
                                    }
                                }
                            },
                    imgs: imgStack.reverse()
                });
            }
        );

this will remove all images after the 3th one from the DOM and loads
them one be one only when nececary. As you can see I had to add the
'removeAttr("src")' in line 4.

If I omit this last part the images will be requested from the server
even though I have removed the elements from the DOM. Is this the
correct behavior because it seems a bit silly to me to request images
that are not in the dom anymore. Or am I missing something and using
it completly the wrong way.

I would rather use the makeArray method en cut my jQuery after the
remove() but it gives me the same issue. Allthough the items are not
supposed to be in the DOM the images are still being downloaded...

Thanks,

Wes

Reply via email to