From 62cd74a890ea3b150c77482d746a716d5001a323 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Tue, 9 Oct 2018 11:08:09 +0200 Subject: [PATCH] add note about lazy loading iframes #1672 #1938 --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 72d2ac9..c60e6a4 100644 --- a/README.md +++ b/README.md @@ -517,7 +517,7 @@ If there's some part of your content that needs to remain accessible to touch ev When working on presentation with a lot of media or iframe content it's important to load lazily. Lazy loading means that reveal.js will only load content for the few slides nearest to the current slide. The number of slides that are preloaded is determined by the `viewDistance` configuration option. -To enable lazy loading all you need to do is change your `src` attributes to `data-src` as shown below. This is supported for image, video, audio and iframe elements. Lazy loaded iframes will also unload when the containing slide is no longer visible. +To enable lazy loading all you need to do is change your `src` attributes to `data-src` as shown below. This is supported for image, video, audio and iframe elements. ```html
@@ -530,6 +530,12 @@ To enable lazy loading all you need to do is change your `src` attributes to `da
``` +#### Lazy Loading Iframes +Note that lazy loaded iframes ignore the `viewDistance` configuration and will only load when their containing slide becomes visible. Iframes are also unloaded as soon as the slide is hidden. + +When we lazy load a video or audio element, reveal.js won't start playing that content until the slide becomes visible. However there is no way to control this for an iframe since that could contain any kind of content. That means if we loaded an iframe before the slide is visible on screen it could begin playing media and sound in the background. + + ### API The `Reveal` object exposes a JavaScript API for controlling navigation and reading state: