Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8307377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:30:47+00:00 2026-06-08T18:30:47+00:00

The Problem: I’ve been trying to create a site that houses embeded iframes (8tracks.com

  • 0

The Problem:

I’ve been trying to create a site that houses embeded iframes (8tracks.com playlists) in the slides in AnythingSlider. Everything works smoothly and behaves fine with the embeded iframes once the page is fully loaded, its just I have so much content (8 different genre slide panels) that it takes over 30 secs in some cases to load all 8 slide panels as one big hit so I’d like to lazy load the embeded iframes content as the slide pages are requested but I’m having trouble adapting the image lazy load coding for this purpose.

Attempted Thus Far:

I figured I could simply swap the img tag reference from the AnythingSlider documented lazy load coding for images with that of an iframe and since they are both just references to an src it would work, but this has thus far proven to not be the case. The code below enables lazy loading for images within the gallery, however switching it to iframe has not worked so far:

// This part of the code is
// for demo purposes only
// *************************
    var message = function(file, p, l) {
    var txt = l ? '<i>loading #' + p + '</i>' : '<b>preventing load #' + p + '</b>';
    // show loading message
    $('.message').append('<li>' + txt + ': ' + file + '</li>').find('li:first').remove();
};
// The code above is for this demo only
// *************************

// load image
var loadImg = function(slider, page) {
    slider.$items.eq(page).find('iframe').each(function() {
        if ($(this).attr('src') === '') {
            var newsrc = $(this).attr('data-src');
            $(this).attr('src', newsrc);

            // update loading message
            message(newsrc, page, true); // *** for demo only ***
        }
    });
};

$('#slider').anythingSlider({

resizeContents: false,

// *********** Callbacks ***********
// Callback when the plugin finished initializing
onInitialized: function(e, slider) {
    var start = slider.options.startPanel;
    // allow start & cloned panel images to load
    // the rest get the src removed.
    slider.$items.eq(start).siblings(':not(.cloned)').find('iframe').each(function() {
        var $el = $(this);
        $el.attr('src', function(i, src) {
            if (src !== '') {
                $el.attr('data-src', src);

                // update loading message
                message(src, i + 1, false); // *** for demo only ***
            }
            return '';
        });
    });
    // load current image
    loadImg(slider, slider.currentPage);
    // load first cloned slide #0
    loadImg(slider, 0);
    // load last cloned slide #6
    loadImg(slider, slider.pages+1);
},

// Callback when slide initiates, before control animation
onSlideInit: function(e, slider) {
    // preload the targeted page image
    loadImg(slider, slider.targetPage);
}

});

If you could even help point me in the right direction for this I would be very appreciative as this is pretty much the last little issue I have left to yet resolve within the overall site.

Here is the page’s framework with all needed components as a zip packet (200kb) linked from my dropbox if it helps..
http://dl.dropbox.com/u/23417244/AnythingSlider.zip

Thanks so much for the assistance!!
-Brad

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:30:49+00:00Added an answer on June 8, 2026 at 6:30 pm

    The main issue with the way this demo is set up is that it loads the currently displayed slide and the cloned slides. So if the user is on the first slide, it will load a total of 12 iframes. If they start on any other page, it will load an additional 7-8 iframes.

    So the easiest solution would be to either set the infiniteSlides option or set the slider to use mode: 'fade'. Either of these solutions will not include cloned slide panels in the slider and thus the slider will only load the current page of iframes (5-8 iframes).

    Anyway, I had to combine the AnythingSlider initialization codes – the second one with the lazy loading code was ignored because AnythingSlider was already initialized.

    Try this code (demo):

    jQuery(function($){
        // This part of the code is
        // for demo purposes only
        // *************************
        var message = function(file, p, l) {
            var txt = l ? '<i>loading #' + p + '</i>' : '<b>preventing load #' + p + '</b>';
            // show loading message
            $('.message').append('<li>' + txt + ': ' + file + '</li>').find('li:first').remove();
        };
        // The code above is for this demo only
        // *************************
    
        // load image
        var loadImg = function(slider, page) {
            console.debug('iframe? ' + slider.$items.eq(page).find('iframe').length);
            slider.$items.eq(page).find('iframe').each(function() {
                if ($(this).attr('src') === '') {
                    var newsrc = $(this).attr('data-src');
                    $(this).attr('src', newsrc);
                    // update loading message
                    message(newsrc, page, true); // *** for demo only ***
                }
            });
        };
    
        $('#slider').find('iframe').each(function() {
            var $el = $(this);
            $el.attr('src', function(i, src) {
                if (src !== '') {
                    $el.attr('data-src', src);
                    // update loading message
                    message(src, i + 1, false); // *** for demo only ***
                }
                return '';
            });
        });
    
        $('#slider').anythingSlider({
    
            resizeContents: false,
            buildStartStop      : false,
            navigationFormatter : function(index, panel){ // Format navigation labels with text
                return ['Featured', 'Hip Hop', 'Dubstep', 'D&B', 'Midnight Trip', 'Dance Party', 'Chillin Beats', 'Sexy'][index - 1];
            },
    
            // *********** Callbacks ***********
            // Callback when the plugin finished initializing
            onInitialized: function(e, slider) {
                // load current image
                loadImg(slider, slider.currentPage);
                // load first cloned slide #0
                loadImg(slider, 0);
                // load last cloned slide #6
                loadImg(slider, slider.pages+1);
            },
    
            // Callback when slide initiates, before control animation
            onSlideInit: function(e, slider) {
                // preload the targeted page image
                loadImg(slider, slider.targetPage);
            }
    
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: Trying to create a Mix that is applied to the AVPlayerItem, but it
Problem occured when i tried to display xml data that has been taken by
I'm trying to create an if statement in PHP that prevents a single post
PRoblem: i'm trying to create (just for fun) a simple poker card (with a
Problem: I have a struct of a fixed size that I'm trying to marshal.
Problem: Been struggling to get my code to load external shaders and it is
Problem: I have a table that prints out vertical but I would like it
Problem: I am trying to build a recursive tree using a function and data
Problem: I'm working on a website where there is a dial that displays a
Problem: I have 2 classes, DB class and a User class, that will work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.