1.srcå¾è·å¾çè·¯å¾ï¼ä¼ç´æ¥å è½½ã
å¦<img src="">ï¼å® æ¯æ åçHTMLè¯è¨ æµè§å¨é½è½æ¯æ
2.lazy_srcå¾è·å¾çè·¯å¾ï¼ä½æ¯ä¸ä¼ç´æ¥å è½½ï¼å®æ¯å»¶è¿å è½½å¾çè·¯å¾çJSæ件ï¼å¯¹äºæäºæµè§å¨æ¥è¯´èªç¶æ æ³è¯å«
延æ¶ä»£ç ï¼
<script src="jquery-1.11.1.js"></script>
<script>
$(document).ready(function () {
$(window).scroll(function () {
loadImg();
})
function loadImg() {
$("img").each(function () {
if ($(this).offset().top < $(window).height() * 2 + $(window).scrollTop()) {
$(this).attr("src", $(this).attr("lazy_src")).removeAttr("lazy_src");
}
});
}
})
</script>
温馨提示:答案为网友推荐,仅供参考