WIP new image analizis module in Phantomas
This commit is contained in:
@@ -47,6 +47,7 @@ var PhantomasWrapper = function() {
|
||||
|
||||
// Mandatory
|
||||
'analyze-css': true,
|
||||
'analyze-images': true,
|
||||
'ignoreSslErrors': true, // until Phantomas 2.1
|
||||
'ignore-ssl-errors': true // for Phantomas >= 2.2
|
||||
};
|
||||
@@ -80,6 +81,12 @@ var PhantomasWrapper = function() {
|
||||
offenders: results.getAllOffenders()
|
||||
};
|
||||
|
||||
// Special rules here
|
||||
if (task.options.device !== 'phone') {
|
||||
delete json.metrics.imagesExcessiveDensity;
|
||||
delete json.offenders.imagesExcessiveDensity;
|
||||
}
|
||||
|
||||
deferred.resolve(json);
|
||||
}).
|
||||
catch(res => {
|
||||
|
||||
@@ -14,13 +14,13 @@ var async = require('async');
|
||||
var request = require('request');
|
||||
var md5 = require('md5');
|
||||
|
||||
var imageOptimizer = require('./imageOptimizer');
|
||||
//var imageOptimizer = require('./imageOptimizer');
|
||||
var fileMinifier = require('./fileMinifier');
|
||||
var gzipCompressor = require('./gzipCompressor');
|
||||
var brotliCompressor = require('./brotliCompressor');
|
||||
var contentTypeChecker = require('./contentTypeChecker');
|
||||
var fontAnalyzer = require('./fontAnalyzer');
|
||||
var imageDimensions = require('./imageDimensions');
|
||||
//var imageDimensions = require('./imageDimensions');
|
||||
|
||||
|
||||
var Redownload = function() {
|
||||
@@ -76,9 +76,9 @@ var Redownload = function() {
|
||||
|
||||
.then(contentTypeChecker.checkContentType)
|
||||
|
||||
.then(imageOptimizer.optimizeImage)
|
||||
//.then(imageOptimizer.optimizeImage)
|
||||
|
||||
.then(imageDimensions.getDimensions)
|
||||
//.then(imageDimensions.getDimensions)
|
||||
|
||||
.then(fileMinifier.minifyFile)
|
||||
|
||||
@@ -151,12 +151,12 @@ var Redownload = function() {
|
||||
});
|
||||
|
||||
// Image compression
|
||||
offenders.imageOptimization = listImagesNotOptimized(results);
|
||||
metrics.imageOptimization = offenders.imageOptimization.totalGain;
|
||||
//offenders.imageOptimization = listImagesNotOptimized(results);
|
||||
//metrics.imageOptimization = offenders.imageOptimization.totalGain;
|
||||
|
||||
// Image width
|
||||
offenders.imagesTooLarge = listImagesTooLarge(results, data.params.options.device);
|
||||
metrics.imagesTooLarge = offenders.imagesTooLarge.length;
|
||||
//offenders.imagesTooLarge = listImagesTooLarge(results, data.params.options.device);
|
||||
//metrics.imagesTooLarge = offenders.imagesTooLarge.length;
|
||||
|
||||
// File minification
|
||||
offenders.fileMinification = listFilesNotMinified(results);
|
||||
@@ -341,7 +341,7 @@ var Redownload = function() {
|
||||
}
|
||||
|
||||
|
||||
function listImagesNotOptimized(requests) {
|
||||
/*function listImagesNotOptimized(requests) {
|
||||
var results = {
|
||||
totalGain: 0,
|
||||
images: []
|
||||
@@ -396,9 +396,9 @@ var Redownload = function() {
|
||||
}
|
||||
});
|
||||
return results;
|
||||
}
|
||||
}*/
|
||||
|
||||
function listImagesTooLarge(requests, device) {
|
||||
/*function listImagesTooLarge(requests, device) {
|
||||
var results = [];
|
||||
|
||||
requests.forEach(function(req) {
|
||||
@@ -423,7 +423,7 @@ var Redownload = function() {
|
||||
});
|
||||
|
||||
return results;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
function listFilesNotMinified(requests) {
|
||||
|
||||
Reference in New Issue
Block a user