jQuery Infinite Scrolling/Lazy Loading

后端 未结 4 773

I\'m currently redesigning my website and have been looking into using JavaScript and jQuery. Here is what I have so far: http://www.tedwinder.co.uk/gallery2/.

My vi

4条回答
  •  [愿得一人]
    2020-12-25 13:52

    You can try this jQuery plugin I wrote that uses html comments to lazy load any arbitrary bits of html, including images:

    jQuery Lazy Loader Blog Post

    jQuery Lazy Loader Plugin Page

    Here's an example:

    
     –>
    Any, html css img background, whatever.  
    –>

    So basically you wrap the content you want to lazy load with a placeholder tag and and inner html comment. When the placeholder becomes visible in the viewport, it is replaced with the html string inside the comment.

    You can use any tag for the placeholder but I like pre because it renders as 0 dimension when there's only a comment inside.

    Hope this helps! @MW_Collins

提交回复
热议问题