|
@@ -26,7 +26,9 @@ exports.module = function(phantomas) {
|
|
path,
|
|
path,
|
|
processedImages = {},
|
|
processedImages = {},
|
|
src,
|
|
src,
|
|
- viewportHeight = window.innerHeight;
|
|
|
|
|
|
+ viewportHeight = window.innerHeight,
|
|
|
|
+ // Add an offset of 100px under the height of the screen
|
|
|
|
+ LAZYLOAD_OFFSET = 100;
|
|
|
|
|
|
phantomas.log('lazyLoadableImages: %d image(s) found, assuming %dpx offset to be the fold', len, viewportHeight);
|
|
phantomas.log('lazyLoadableImages: %d image(s) found, assuming %dpx offset to be the fold', len, viewportHeight);
|
|
|
|
|
|
@@ -64,7 +66,7 @@ exports.module = function(phantomas) {
|
|
Object.keys(processedImages).forEach(function(src) {
|
|
Object.keys(processedImages).forEach(function(src) {
|
|
var img = processedImages[src];
|
|
var img = processedImages[src];
|
|
|
|
|
|
- if (img.offset > viewportHeight) {
|
|
|
|
|
|
+ if (img.offset > viewportHeight + LAZYLOAD_OFFSET) {
|
|
phantomas.log('lazyLoadableImages: <%s> image (%s) is below the fold (at %dpx)', src, img.path, img.offset);
|
|
phantomas.log('lazyLoadableImages: <%s> image (%s) is below the fold (at %dpx)', src, img.path, img.offset);
|
|
|
|
|
|
phantomas.incrMetric('lazyLoadableImagesBelowTheFold');
|
|
phantomas.incrMetric('lazyLoadableImagesBelowTheFold');
|