瀏覽代碼

Created the generic score profile

Gaël Métais 10 年之前
父節點
當前提交
90dac7dd19
共有 2 個文件被更改,包括 118 次插入15 次删除
  1. 14 14
      lib/metadata/policies.json
  2. 104 1
      lib/metadata/scoreProfileGeneric.json

+ 14 - 14
lib/metadata/policies.json

@@ -2,7 +2,7 @@
     "DOMelementsCount": {
         "tool": "phantomas",
         "label": "DOM elements count",
-        "message": "<p>A high number of DOM elements means a lot of work for the browser to render the page.</p><p>It also slows down Javascript DOM queries, as there are more elements to search through.</p>",
+        "message": "<p>A high number of DOM elements means a lot of work for the browser to render the page.</p><p>It also slows down JavaScript DOM queries, as there are more elements to search through.</p>",
         "isOkThreshold": 1000,
         "isBadThreshold": 3000,
         "isAbnormalThreshold": 5000
@@ -10,7 +10,7 @@
     "DOMelementMaxDepth": {
         "tool": "phantomas",
         "label": "DOM max depth",
-        "message": "<p>A deep DOM makes the CSS matching with DOM elements difficult.</p><p>It also slows down Javascript modifications to the DOM because changing the dimensions of an element makes the browser re-calculate the dimensions of it's parents. Same thing for Javascript events, that bubble up to the document root.</p>",
+        "message": "<p>A deep DOM makes the CSS matching with DOM elements difficult.</p><p>It also slows down JavaScript modifications to the DOM because changing the dimensions of an element makes the browser re-calculate the dimensions of it's parents. Same thing for JavaScript events, that bubble up to the document root.</p>",
         "isOkThreshold": 10,
         "isBadThreshold": 20,
         "isAbnormalThreshold": 30
@@ -34,7 +34,7 @@
     "DOMinserts": {
         "tool": "phantomas",
         "label": "DOM inserts",
-        "message": "<p>Working with the DOM in Javascript triggers layout calculations and slows down the page.</p><p>Try, as much as possible, to have an HTML page fully generated by the server instead of making changes with JS.</p>",
+        "message": "<p>Working with the DOM in JavaScript triggers layout calculations and slows down the page.</p><p>Try, as much as possible, to have an HTML page fully generated by the server instead of making changes with JS.</p>",
         "isOkThreshold": 10,
         "isBadThreshold": 400,
         "isAbnormalThreshold": 1000
@@ -42,7 +42,7 @@
     "DOMqueries": {
         "tool": "phantomas",
         "label": "DOM queries",
-        "message": "<p>DOM queries are like looking in a large catalog of items. Even if the browsers made progress on the performances of queries, websites often make hundreds of them.</p><p>Try to reduce the number of queries by refactoring your Javascript code.</p><p>Avoid also to have a read query between two write queries. To be able to reduce the number repaints and optimize performances, browsers buffer the DOM writing operations and treat them in bulk. But each time a DOM reading is asked, the browser needs to empty the buffer. This can be particularly slow inside a loop.</p>",
+        "message": "<p>DOM queries are like looking in a large catalog of items. Even if the browsers made progress on the performances of queries, websites often make hundreds of them.</p><p>Try to reduce the number of queries by refactoring your JavaScript code.</p><p>Avoid also to have a read query between two write queries. To be able to reduce the number repaints and optimize performances, browsers buffer the DOM writing operations and treat them in bulk. But each time a DOM reading is asked, the browser needs to empty the buffer. This can be particularly slow inside a loop.</p>",
         "isOkThreshold": 50,
         "isBadThreshold": 1000,
         "isAbnormalThreshold": 2000
@@ -65,7 +65,7 @@
     },
     "jsErrors": {
         "tool": "phantomas",
-        "label": "Javascript errors",
+        "label": "JavaScript errors",
         "message": "<p>Just to let you know there are some errors on the page.</p><p><b>Please note that some errors only occur in the PhantomJS browser, so you might need to double check on other browsers.</b></p>",
         "isOkThreshold": 0,
         "isBadThreshold": 1,
@@ -106,7 +106,7 @@
     "inBodyDomManipulations": {
         "tool": "ylt",
         "label": "DOM manipulations in body",
-        "message": "<p>This metric counts the number of DOM queries, DOM inserts, binds, etc. made by the Javascript before the DOMContentLoaded event.</p><p>Wait for this event before manipulating the DOM. Do not execute Javascript in the middle of the BODY as it slows down the construction of the DOM and makes a poor maintainability. This is what i call spaghetti code.</p><p>The JS Timeline tab can help you identify what's happening.</p>",
+        "message": "<p>This metric counts the number of DOM queries, DOM inserts, binds, etc. made by the JavaScript before the DOMContentLoaded event.</p><p>Wait for this event before manipulating the DOM. Do not execute JavaScript in the middle of the BODY as it slows down the construction of the DOM and makes a poor maintainability. This is what i call spaghetti code.</p><p>The JS Timeline tab can help you identify what's happening.</p>",
         "isOkThreshold": 10,
         "isBadThreshold": 50,
         "isAbnormalThreshold": 100
@@ -125,6 +125,14 @@
         "message": "<p>jQuery is a heavy library. You should <b>never<b> load jQuery more than one on the same page.</p>",
         "isOkThreshold": 1,
         "isBadThreshold": 2,
+        "isAbnormalThreshold": 2
+    },
+    "cssParsingErrors": {
+        "tool": "phantomas",
+        "label": "CSS syntax error",
+        "message": "<p>Yellow Lab Tools failed to parse a CSS file. I doubt the problem comes from the css parser.</p><p>Maybe a <a href=\"http://jigsaw.w3.org/css-validator\" target=\"_blank\">CSS validator</a> can help you.</p>",
+        "isOkThreshold": 1,
+        "isBadThreshold": 2,
         "isAbnormalThreshold": 3
     },
     "cssRules": {
@@ -151,14 +159,6 @@
         "isBadThreshold": 50,
         "isAbnormalThreshold": 100
     },
-    "cssParsingErrors": {
-        "tool": "phantomas",
-        "label": "CSS syntax error",
-        "message": "<p>Yellow Lab Tools failed to parse a CSS file. I doubt the problem comes from the css parser.</p><p>Maybe a <a href=\"http://jigsaw.w3.org/css-validator\" target=\"_blank\">CSS validator</a> can help you.</p>",
-        "isOkThreshold": 1,
-        "isBadThreshold": 2,
-        "isAbnormalThreshold": 3
-    },
     "cssImports": {
         "tool": "phantomas",
         "label": "Uses of @import",

+ 104 - 1
lib/metadata/scoreProfileGeneric.json

@@ -1,3 +1,106 @@
 {
-    
+    "categories": {
+        "domComplexity": {
+            "label": "DOM complexity",
+            "policies": {
+                "DOMelementsCount": 1,
+                "DOMelementMaxDepth": 1,
+                "iframesCount": 1,
+                "DOMidDuplicated": 1
+            }
+        },
+        "domManipulations": {
+            "label": "DOM manipulations",
+            "policies": {
+                "DOMinserts": 2,
+                "DOMqueries": 1,
+                "DOMqueriesAvoidable": 2,
+                "eventsBound": 1
+            }
+        },
+        "badJavascript": {
+            "label": "Bad JavaScript",
+            "policies": {
+                "jsErrors": 2,
+                "evalCalls": 1,
+                "documentWriteCalls": 2,
+                "consoleMessages": 0.5,
+                "globalVariables": 0.5,
+                "inBodyDomManipulations": 1
+            }
+        },
+        "jQueryVersion": {
+            "label": "jQuery version",
+            "policies": {
+                "jQueryVersion": 1,
+                "jQueryDifferentVersions": 5
+            }
+        },
+        "cssSyntaxError": {
+            "label": "CSS syntax errors",
+            "policies": {
+                "cssParsingErrors": 1
+            }
+        },
+        "cssComplexity": {
+            "label": "CSS complexity",
+            "policies": {
+                "cssRules": 2,
+                "cssComplexSelectors": 2,
+                "cssComplexSelectorsByAttribute": 1.5
+            }
+        },
+        "badCSS": {
+            "label": "Bad CSS",
+            "policies": {
+                "cssImports": 3,
+                "cssDuplicatedSelectors": 2,
+                "cssDuplicatedProperties": 1,
+                "cssEmptyRules": 2,
+                "cssExpressions": 1,
+                "cssImportants": 3,
+                "cssOldIEFixes": 1,
+                "cssOldPropertyPrefixes": 1,
+                "cssUniversalSelectors": 1,
+                "cssRedundantBodySelectors": 1,
+                "cssRedundantChildNodesSelectors": 1
+            }
+        },
+        "requests": {
+            "label": "Requests number",
+            "policies": {
+                "request": 5,
+                "htmlCount": 0,
+                "jsCount": 1,
+                "cssCount": 1,
+                "imageCount": 0,
+                "webfontCount": 2,
+                "videoCount": 0,
+                "jsonCount": 0,
+                "otherCount": 0
+            }
+        },
+        "network": {
+            "label": "Network",
+            "policies": {
+                "notFound": 3,
+                "closedConnections": 3,
+                "multipleRequests": 3,
+                "cachingDisabled": 1,
+                "cachingTooShort": 1,
+                "domains": 1
+            }
+        }
+    },
+    "globalScore": {
+        "domComplexity": 1,
+        "domManipulations": 2,
+        "badJavascript": 1,
+        "jQueryVersion": 1,
+        "cssSyntaxError": 1,
+        "cssComplexity": 1,
+        "badCSS": 1,
+        "requests": 3,
+        "network": 2
+    }
 }