2012-09-05 32 views
5

Tôi có một trang trình bày chu trình jQuery chứa khoảng 48 trang trình bày. Vấn đề là tải ban đầu của tất cả các tài sản mất một thời gian để trang bị méo trong khoảng 1-5 giây. Có cách nào để lười tải các tài sản cần thiết cho mỗi slide chỉ khi slide được gọi hay slide được biết là slide trước hoặc tiếp theo?jQuery Cycle Lazy Loading

Trả lời

5

Các jquery cycle2 Plugin cho phép để tải tiến bộ: http://jquery.malsup.com/cycle2/demo/progressive.php

<div class="cycle-slideshow auto" 
    data-cycle-fx="scrollHorz" 
    data-cycle-timeout="2000" 
    data-cycle-caption=".caption1" 
    data-cycle-caption-template="{{slideNum}}/9" 
    data-cycle-loader="true" 
    data-cycle-progressive="#images" 
    > 
    <!-- only one image declared in markup --> 
    <img src="http://jquery.malsup.com/cycle2/images/beach1.jpg"> 

    <!-- 
     JSON array of slides to be loaded progressively, 
     nested inside a script block. The script block does not need 
     to be inslide the slideshow container, it can be anywhere on the 
     page. Note the type on the script tag. 
    --> 
    <script id="images" type="text/cycle"> 
[ 
    "<img src='http://jquery.malsup.com/cycle2/images/beach2.jpg'>", 
    "<img src='http://jquery.malsup.com/cycle2/images/beach3.jpg'>", 
    ... 
    "<img src='http://jquery.malsup.com/cycle2/images/beach9.jpg'>" 
] 
</script> 
</div> 
<div class="center caption1"></div>