Total Weight offenders

This commit is contained in:
Gaël Métais
2015-05-30 12:52:50 +02:00
parent 7b64288765
commit d7ddae38e5
11 changed files with 144 additions and 45 deletions
+10
View File
@@ -852,6 +852,16 @@ var policies = {
};
}
},
"totalWeight": {
"tool": "weightChecker",
"label": "Total weight",
"message": "<p>The weight is of course very important if you want the page to load fast. Try to stay under 1MB, which is alreay very long to download over a slow connection.</p>",
"isOkThreshold": 716800,
"isBadThreshold": 2097152,
"isAbnormalThreshold": 3145728,
"hasOffenders": true,
"unit": 'bytes'
},
"requests": {
"tool": "phantomas",
"label": "Total requests number",
+21 -31
View File
@@ -3,7 +3,7 @@
"domComplexity": {
"label": "DOM complexity",
"policies": {
"DOMelementsCount": 1,
"DOMelementsCount": 3,
"DOMelementMaxDepth": 1,
"iframesCount": 1,
"DOMidDuplicated": 1
@@ -69,44 +69,34 @@
"cssRedundantChildNodesSelectors": 1
}
},
"pageWeight": {
"label": "Page weight",
"policies": {
"totalWeight": 5
}
},
"requests": {
"label": "Requests number",
"label": "Requests",
"policies": {
"requests": 5,
"htmlCount": 0,
"jsCount": 1,
"cssCount": 1,
"imageCount": 0,
"webfontCount": 2,
"videoCount": 0,
"jsonCount": 0,
"otherCount": 0
}
},
"smallRequests": {
"label": "Small requests",
"policies": {
"smallJsFiles": 1,
"smallCssFiles": 1,
"smallImages": 1
}
},
"network": {
"label": "Network",
"policies": {
"notFound": 2,
"assetsNotGzipped": 1.5,
"closedConnections": 2,
"domains": 3,
"notFound": 3,
"multipleRequests": 2,
"smallRequests": 1
}
},
"serverConfig": {
"label": "Server config",
"policies": {
"closedConnections": 2,
"cachingNotSpecified": 1,
"cachingDisabled": 1,
"cachingTooShort": 1,
"domains": 1
"cachingTooShort": 1
}
}
},
"globalScore": {
"domComplexity": 1,
"domComplexity": 2,
"domManipulations": 2,
"scroll": 1,
"badJavascript": 1,
@@ -114,8 +104,8 @@
"cssSyntaxError": 1,
"cssComplexity": 1,
"badCSS": 1,
"pageWeight": 3,
"requests": 3,
"smallRequests": 1,
"network": 2
"serverConfig": 1
}
}
+1 -1
View File
@@ -102,7 +102,7 @@ var WeightChecker = function() {
};
requests.forEach(function(req) {
var weight = (typeof req.weightCheck.bodySize === 'number') ? req.weightCheck.bodySize + req.weightCheck.headersSize : req.contentLength;
var weight = ((typeof req.weightCheck.bodySize === 'number') ? req.weightCheck.bodySize + req.weightCheck.headersSize : req.contentLength) || 0;
var type = req.type || 'other';
results.totalWeight += weight;