function lazyloadimages() { const images = document.queryselectorall('img[data-src]'); const options = { root: null, // �ӵ���ϊ��Ԫ�� rootmargin: '0px', threshold: 0.2 // ��ͼƭ�ﵽ�ӵ��� 20% ����ʼ���� }; // ͼƭ�����ӵ�ʱ���� function onintersection(entries) { entries.foreach(entry => { if (entry.intersectionratio>0&&entry.target.src=='') { entry.target.src = entry.target.dataset.src; observer.unobserve(entry.target); } }); } const observer = new intersectionobserver(onintersection, options); images.foreach(image => { observer.observe(image); }); } document.addeventlistener('scroll',lazyloadimages)