2

我在 WordPress 主题上使用 owl carousel。3 个轮播显示在首页 - 第 4 个显示在内页。

在加载首页时,它不会响应任何鼠标操作约 1-2 秒。它像大多数 CPU 一样被使用,但随后加载正常。我可以在下面的代码中更改某些内容以提高性能吗?

        (function($) {
            $(document).ready(function() { 
                $('.tooltip-link').tooltip({ placement: 'top'});

                var owl1 = $(".carousel-one");
                owl1.owlCarousel({
                  autoPlay: <?php if (of_get_option('of_pause') == '0' ) { echo '999999'; } else { echo of_get_option('of_pause') . '000'; } ?>,
                  pagination:false,
                  itemsDesktop :    [2500,2],
                  itemsDesktopSmall :   [1000,2],
                  itemsMobile :     [679,1],
                  mouseDrag: false,
                  touchDrag: false
                }); 
                $(".carousel-one-next").click(function(){
                    owl1.trigger('owl.next');
                })
                $(".carousel-one-prev").click(function(){
                    owl1.trigger('owl.prev');
                })

                var owl2 = $(".carousel-two");
                owl2.owlCarousel({
                  autoPlay: <?php if (of_get_option('of_pause2') == '0' ) { echo '999999'; } else { echo of_get_option('of_pause2') . '000'; } ?>,
                  pagination:true,
                  itemsDesktop :    [2500,4],
                  itemsDesktopSmall :   [1000,3],
                  itemsMobile :     [679,2],
                  mouseDrag: false,
                  touchDrag: false                    
                }); 
                $(".carousel-two-next").click(function(){
                    owl2.trigger('owl.next');
                })
                $(".carousel-two-prev").click(function(){
                    owl2.trigger('owl.prev');
                })  

                var owl3 = $(".carousel-three");
                owl3.owlCarousel({
                  autoPlay: <?php if (of_get_option('of_pause3') == '0' ) { echo '999999'; } else { echo of_get_option('of_pause3') . '000'; } ?>,
                  pagination:false,
                  itemsDesktop :    [2500,3],
                  itemsDesktopSmall :   [1000,3],
                  itemsMobile :     [679,2],
                  mouseDrag: false,
                  touchDrag: false                    
                }); 
                $(".carousel-three-next").click(function(){
                    owl3.trigger('owl.next');
                })
                $(".carousel-three-prev").click(function(){
                    owl3.trigger('owl.prev');
                })

                var owl4 = $(".carousel-four");
                owl4.owlCarousel({
                  autoPlay: <?php if (of_get_option('of_pause4') == '0' ) { echo '999999'; } else { echo of_get_option('of_pause4') . '000'; } ?>,
                  pagination:true,
                  singleItem : true,
                  autoHeight : true,
                  mouseDrag: false,
                  touchDrag: false                    
                }); 
                $(".carousel-four-next").click(function(){
                    owl4.trigger('owl.next');
                })
                $(".carousel-four-prev").click(function(){
                    owl4.trigger('owl.prev');
                })                              
            });
        })(jQuery);
4

0 回答 0