ressio / lazy-load-xt

Lazy load XT is a jQuery plugin for images, videos and other media
http://ress.io/lazy-load-xt-jquery/
MIT License
1.36k stars 243 forks source link

How to lazy load other html tags <p> <span> <div> ? #9

Open kapil-zepo opened 10 years ago

kapil-zepo commented 10 years ago

Hey,

Appreciate the work done. Just need one help, in options you have set selector as selector: 'img[data-src]', // selector for lazyloading elements

How can we include other tags, if we want to implement lazy load on those tags, viz."div", "span", "p" etc.

Any hack to this would help. Thanks. Keep up the good work. :)

dryabov commented 10 years ago

Could you give me an example of what you would like to get? In the case of <img> tag. Lazy Load XT just change src attribute that is not the case of <p> tag. Most likely you think about something similar to widget addon, but it is better to start discussion with clear idea.

kapil-zepo commented 10 years ago

I need to lazy load my content(text) also, instead of just image. Is it possible? Am i clear this time?

dryabov commented 10 years ago

I've added simple lazyloadxt.html addon: https://github.com/ressio/lazy-load-xt/blob/master/src/jquery.lazyloadxt.html.js

The usage is very simple:

<script src="jquery.lazyloadxt.js"></script>
<script src="jquery.lazyloadxt.html.js"></script>
...
<p data-lazy-src="/url/to/lazy/load/in/p/tag.htm"></p>

Is it that you like to get?

PS. Note that currently it is just a draft and the addon may be modified further.

kapil-zepo commented 10 years ago

Yes something like that, where we can lazy load text even... You can check an example here on this page. http://theme.concept7.vn/concept1/

Thanks for your reply. Do provide a possible solution if feasible.

ghost commented 10 years ago

LazyLoading is obviously mostly for performance reasons, but sometimes I just want to hide content and "reveal it" (usually with a fade) as the visitor scrolls down the page, so it'd be great to be able to do this with any element (div/section/etc.) in a similar way described here. As I understand, the simple add-on you've created here literally loads the content in on-the-fly, but what about if I want the content to be there in the first place, but just 'revealed'? That method would be better for SEO, but it's obviously technically not "lazy loading" so I understand it is probably beyond the scope of this plugin, however, the logic for revealing things based on element position/visibility is already there, so it'd be great to re-use the plugin for this purpose too. I'd like to know your thoughts on this.