High performance and SEO friendly lazy loader for images (responsive and normal), iframes and more, that detects any visibility changes triggered through user interaction, CSS or JavaScript without configuration.
MIT License
17.56k
stars
1.73k
forks
source link
Lazy load $.ajax requests without having access to the final html output #373
I have a modal with loads (more than 50 sometimes) third party embeds from different sources (twitter, instagram, facebook posts, facebook videos, ...).
All of them are launched using oembed (standardized embed format)
So I can't really add classes diretcly to the iframes as they're not in my actual codebase.
I am using lazysizes lazy load library for lazy loading standard images. But I fail to do lazy load my ajax requests that is to say I want that my $.ajax (embed_request) are only launched/executed when the corresponding area it belongs to (via the id=item1, item2...) is inside the viewport or at less than 300pixels of the viewport.
I have a modal with loads (more than 50 sometimes) third party embeds from different sources (twitter, instagram, facebook posts, facebook videos, ...).
All of them are launched using oembed (standardized embed format)
All those ajax $.ajax will outout an html such as for facebook posts:
<iframe name="f2d29ksdksd24" width="750px" height="1000px" frameborder="0" allowtransparency="true" allowfullscreen="true" scrolling="no" title="fb:post Facebook Social Plugin" src="https://www.facebook.com/v2.3/plugins/post.php?app_id=&channel=http%3A%2F%2Fstaticxx.facebook.com%2Fconnect%2Fxd_arbiter%2Fr%2F1FegrZjPbq3.js%3Fversion%3D42%23cb%3Df39db5bcb71e548%26domain%example" style="border: none; visibility: visible; width: 750px; height: 516px;" class=""></iframe>
So I can't really add classes diretcly to the iframes as they're not in my actual codebase.
I am using lazysizes lazy load library for lazy loading standard images. But I fail to do lazy load my ajax requests that is to say I want that my $.ajax (embed_request) are only launched/executed when the corresponding area it belongs to (via the id=item1, item2...) is inside the viewport or at less than 300pixels of the viewport.