Slider (flexslider) NOT loading fast enough on page load?

冷暖自知 提交于 2020-01-06 16:19:51

问题


A massive problem at the moment is that my flexslider DOES NOT load fast enough. The images that are dynamically loaded into the slider from the network report on google chrome show that they aren't loading fast enough.

Theres a big enough delay that im not very happy and ideally would like to make the slider and its images loaded as fast as possibly so the user will not have to wait for it to load.

It is script related or DNS related. IM very confused as to why its taking so long to load.


回答1:


I have since edited the script to this. It has seemed to cut the amount of time, but still loads a tad to slow.

   $(document).ready(function () {
        var urls = [
            'http://fantasyfootballpundits.com/football/?category=Captaincy+Analysis&format=json&callback=?',
            'http://fantasyfootballpundits.com/football/?category=The+Gameweek+Preview&format=json&callback=?',
            'http://fantasyfootballpundits.com/football/?category=In+The+News&format=json&callback=?',
            'http://fantasyfootballpundits.com/football/?category=Pundits+Team&format=json&callback=?',
            'http://fantasyfootballpundits.com/football/?category=Shrewd+Moves&format=json&callback=?',
            'http://fantasyfootballpundits.com/football/?category=Shrewd+Moves&format=json&callback=?',
            'http://fantasyfootballpundits.com/football/?category=Guest+Fantasy+Articles&format=json&callback=?'
        ];

        urls.forEach(function (u) {
            $.getJSON(u).done(function (data) {
                var current = data.items[0];
                if (current != null) {
                    var post = '<li><a href="http://fantasyfootballpundits.com' + current.fullUrl + '"><img src= "' + current.assetUrl + '" alt ="' + current.filename + '"></a></li>';
                    $('ul.slides').append(post);
                }
            });
        });

    });


来源:https://stackoverflow.com/questions/17746038/slider-flexslider-not-loading-fast-enough-on-page-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!