diff --git a/src/js/scriptlets/load-large-media-all.js b/src/js/scriptlets/load-large-media-all.js index 182ac1c36..352f2699d 100644 --- a/src/js/scriptlets/load-large-media-all.js +++ b/src/js/scriptlets/load-large-media-all.js @@ -50,13 +50,14 @@ elems = document.querySelectorAll('img'); i = elems.length; while ( i-- ) { elem = elems[i]; - if ( - typeof elem.naturalWidth !== 'number' || - elem.naturalWidth === 0 || - typeof elem.naturalHeight !== 'number' || - elem.naturalHeight === 0 - ) { - src = elem.getAttribute('src') || ''; + if ( elem.naturalWidth !== 0 && elem.naturalHeight !== 0 ) { + continue; + } + if ( window.getComputedStyle(elem).getPropertyValue('display') === 'none' ) { + continue; + } + src = elem.getAttribute('src'); + if ( src ) { elem.removeAttribute('src'); elem.setAttribute('src', src); } diff --git a/src/js/scriptlets/load-large-media-interactive.js b/src/js/scriptlets/load-large-media-interactive.js index fe532b771..ad53c8bbc 100644 --- a/src/js/scriptlets/load-large-media-interactive.js +++ b/src/js/scriptlets/load-large-media-interactive.js @@ -52,8 +52,11 @@ var mediaNotLoaded = function(elem) { case 'video': return elem.error !== null; case 'img': - return elem.offsetWidth !== 0 && elem.offsetHeight !== 0 && - (elem.naturalWidth === 0 || elem.naturalHeight === 0); + if ( elem.naturalWidth === 0 && elem.naturalHeight === 0 ) { + return window.getComputedStyle(elem) + .getPropertyValue('display') !== 'none'; + } + break; default: break; }