hakimel / reveal.js

The HTML Presentation Framework
https://revealjs.com
MIT License
67.57k stars 16.62k forks source link

Lazy load media #793

Closed akaleeroy closed 10 years ago

akaleeroy commented 10 years ago

I'd like to suggest this enhancement. For presentations heavily laden with images and videos, integrate a lazy load plugin. Maybe lazy-load-xt?

hakimel commented 10 years ago

I've noticed this becoming an issue in big presentations as well. Ideally there is some way on improving this in the core of reveal.js.

Idea: On load, reveal.js could move the "src" attribute of media elements to "data-src". Then as you navigate the source attribute is changed back only for the nearest few slides.

[edited the issue title]

akaleeroy commented 10 years ago

That would be most elegant.

hakimel commented 10 years ago

Lazy loading support has been added and works with image, video and audio elements. This feature requires changes to presentation markup, more info in the readme: https://github.com/hakimel/reveal.js/blob/dev/README.md#lazy-loading

reagle commented 10 years ago

Sadly, I don't expect to ever take advantage of this as the requirement to change the markup seems onerous. Why not just enable it globally?

hakimel commented 10 years ago

Unfortunately that's the only way to do it. If the presentation markup hits the browser with normal src attributes it's too late, the browser will already have started loading them. Otherwise they could have been replaced entirely via JS.

akaleeroy commented 10 years ago

I love you man! iframe support too, plz!

LOL nevermind... , iframe[data-src],

hakimel commented 10 years ago

@akaleeroy Thanks, forgot about iframes but that's been added now.

yocontra commented 10 years ago

Does this still exist? It doesn't seem to be working and the docs are gone

hakimel commented 10 years ago

@contra It's only available in the dev branch so far. There's still some work getting that branch to 3.0 before it will be merged into master, hopefully I can get back on that soon.

abhinandankothari commented 9 years ago

@hakimel Is this available in 3.1 release or Still in dev branch ?

mb21 commented 7 years ago

Is there ever a reason not to use lazy-loading?

Wondering whether pandoc should output <img data-src instead of <img src when generating reveal.js slides from markdown, see https://github.com/jgm/pandoc/issues/2283 Some feedback would be great before we make the change...

reagle commented 7 years ago

@mb21 see @hakimel above:

Unfortunately that's the only way to do it. If the presentation markup hits the browser with normal src attributes it's too late, the browser will already have started loading them. Otherwise they could have been replaced entirely via JS.

reagle commented 7 years ago

Or are you asking if reveal.js has run into bugs/problems with lazy loading? I've been using it since it became available without problem.

mb21 commented 7 years ago

Yes, I'm asking whether there are any use-cases where it's preferable to not use lazy-loading when making a reveal.js slideshows...

gelinger777 commented 7 years ago

Hi There, the lazy loading is cool, but what about following problem. Let's say we have 10.000-20.000 pages in the presentation, which we need to optimize. The lazy loading only will not help. We need to on moving right or left add the actual HTML of the upcoming 4-5 sections and sections before to the dom and remove tem as user move back and forth. Any implementation or plugin for this sofar?

robertop87 commented 7 years ago

I'm using videos with lazy loading, but at the beginning all then are loaded in memory, is it OK? I supposed that lazy loading means to have only play asset in the memory.

dberardo-com commented 1 year ago

is lazy loading also working with regular html code? lets assume having some very heavy animation, or heavy script tags that need to be executed when the slides shows, is it possible to use lazy loading without iframe in such case ?

and if iframes are required, can regular HTML code be embedded within them ?