阻止Flexslider加载所有照片

时间:2018-10-16 14:59:47

标签: wordpress optimization flexslider

有什么方法可以添加代码,以防止flexslider加载所有照片。我有wp-rocket,所有图片加载都不错,唯一的flexslider需要22秒才能显示出来。这是我现在用于图库滑块的代码。以及指向带有滑块https://wnfdiary.com/kad-kokoa-review-chocolate-bangkok/

的博客文章的链接
    <?php header("content-type: application/x-javascript"); ?>
<?php
$absolute_path = __FILE__;
$path_to_file = explode( 'wp-content', $absolute_path );
$path_to_wp = $path_to_file[0];
require_once $path_to_wp.'/wp-load.php';

$autoplay = 'true';
$timer = 5;
$caption = 1;

if(isset($_GET['autoplay']) && empty($_GET['autoplay']))
{
    $autoplay = 'false';
}

if(isset($_GET['timer']))
{
    $timer = $_GET['timer'];
}

if(isset($_GET['caption']))
{
    $caption = $_GET['caption'];
}
?>
jQuery(window).load(function(){ 
    jQuery('.slider_wrapper').flexslider({
          animation: "fade",
          animationLoop: true,
          itemMargin: 0,
          minItems: 1,
          maxItems: 1,
          slideshow: <?php echo esc_js($autoplay); ?>,
          controlNav: false,
          smoothHeight: true,
          slideshowSpeed: <?php echo intval($timer*1000); ?>,
          move: 1
    });
});

0 个答案:

没有答案