lazy loading fallback also considers iframes
This commit is contained in:
parent
80e52c08e9
commit
152271efb2
20
js/reveal.js
20
js/reveal.js
|
@ -238,14 +238,18 @@
|
||||||
if( !features.transforms2d && !features.transforms3d ) {
|
if( !features.transforms2d && !features.transforms3d ) {
|
||||||
document.body.setAttribute( 'class', 'no-transforms' );
|
document.body.setAttribute( 'class', 'no-transforms' );
|
||||||
|
|
||||||
// Since JS won't be running any further, we need to load all
|
// Since JS won't be running any further, we load all lazy
|
||||||
// images that were intended to lazy load now
|
// loading elements upfront
|
||||||
var images = document.getElementsByTagName( 'img' );
|
var images = toArray( document.getElementsByTagName( 'img' ) ),
|
||||||
for( var i = 0, len = images.length; i < len; i++ ) {
|
iframes = toArray( document.getElementsByTagName( 'iframe' ) );
|
||||||
var image = images[i];
|
|
||||||
if( image.getAttribute( 'data-src' ) ) {
|
var lazyLoadable = images.concat( iframes );
|
||||||
image.setAttribute( 'src', image.getAttribute( 'data-src' ) );
|
|
||||||
image.removeAttribute( 'data-src' );
|
for( var i = 0, len = lazyLoadable.length; i < len; i++ ) {
|
||||||
|
var element = lazyLoadable[i];
|
||||||
|
if( element.getAttribute( 'data-src' ) ) {
|
||||||
|
element.setAttribute( 'src', element.getAttribute( 'data-src' ) );
|
||||||
|
element.removeAttribute( 'data-src' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue