Add an offset to Below the fold images

This commit is contained in:
Gaël Métais
2016-12-20 16:28:49 +08:00
parent 736d447d9e
commit 9ca126f3cd
@@ -26,7 +26,9 @@ exports.module = function(phantomas) {
path,
processedImages = {},
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);
@@ -64,7 +66,7 @@ exports.module = function(phantomas) {
Object.keys(processedImages).forEach(function(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.incrMetric('lazyLoadableImagesBelowTheFold');