You can try this jQuery plugin I wrote that uses HTML comments to lazily load any arbitrary bits of HTML, including images:
JQuery Lazy Loader Post
JQuery Lazy Loader Plugin Page
Here is an example:
<pre class="i-am-lazy" ><!– <img src="some.png" /> –></pre> <pre class="i-am-lazy" ><!– <div>Any, html css img background, whatever. <img src="some.png" /> </div> –></pre> <script type="text/javascript" src="jquery.lazyloader.js" ></script> <script type="text/javascript" > $(document).ready( function() { $('pre.i-am-lazy').lazyLoad(); }); </script>
So, basically you end the content you want to be lazy, load with the placeholder tag and internal HTML comment. When the placeholder becomes visible in the viewport, it is replaced with an HTML line inside the comment.
You can use any tag for placeholder, but I like pre because it displays as size 0 when there is only a comment inside.
Michael collins
source share