瀏覽代碼

Add Images not lazyloaded rule

Gaël Métais 10 年之前
父節點
當前提交
2f447da34b
共有 5 個文件被更改,包括 16 次插入5 次删除
  1. 1 1
      front/src/css/rule.css
  2. 1 1
      front/src/less/rule.less
  3. 3 2
      front/src/views/rule.html
  4. 9 0
      lib/metadata/policies.js
  5. 2 1
      lib/metadata/scoreProfileGeneric.json

+ 1 - 1
front/src/css/rule.css

@@ -237,7 +237,7 @@
   margin-top: 0.5em;
 }
 .smallPreview {
-  max-height: 1.5em;
+  max-height: 1.6em;
   max-width: 4em;
   border: 1px solid #000;
   margin-top: 0.2em;

+ 1 - 1
front/src/less/rule.less

@@ -262,7 +262,7 @@
 }
 
 .smallPreview {
-    max-height: 1.5em;
+    max-height: 1.6em;
     max-width: 4em;
     border: 1px solid #000;
     margin-top: 0.2em;

+ 3 - 2
front/src/views/rule.html

@@ -137,8 +137,9 @@
                         <file-and-line-button file="offender.file" line="offender.line" column="offender.column"></file-and-line-button>
                     </div>
 
-                    <div ng-if="policyName === 'requests'">
-                        <url-link url="offender.file" max-length="100"></url-link>
+                    <div ng-if="policyName === 'lazyLoadableImagesBelowTheFold'">
+                        <url-link url="offender" max-length="100"></url-link>
+                        <img ng-src="{{offender}}" class="smallPreview checker"></img>
                     </div>
 
                     <div ng-if="policyName === 'notFound' || policyName === 'closedConnections' || policyName === 'multipleRequests' || policyName === 'cachingDisabled' || policyName === 'cachingNotSpecified'">

+ 9 - 0
lib/metadata/policies.js

@@ -910,6 +910,15 @@ var policies = {
         "isAbnormalThreshold": 50,
         "hasOffenders": true
     },
+    "lazyLoadableImagesBelowTheFold": {
+        "tool": "phantomas",
+        "label": "Not lazyloaded images",
+        "message": "<p>This is the number of images displayed below the fold that could be lazy-loaded. This is an excellent way to accelerate the loading time of an heavy page.</p><p>I recommend using <a href=\"https://github.com/vvo/lazyload\" target=\"_blank\">this lazyloader</a>.</p>",
+        "isOkThreshold": 1,
+        "isBadThreshold": 12,
+        "isAbnormalThreshold": 30,
+        "hasOffenders": true
+    },
     "notFound": {
         "tool": "phantomas",
         "label": "404 not found",

+ 2 - 1
lib/metadata/scoreProfileGeneric.json

@@ -85,7 +85,8 @@
                 "domains": 3,
                 "notFound": 3,
                 "multipleRequests": 2,
-                "smallRequests": 1
+                "smallRequests": 1,
+                "lazyLoadableImagesBelowTheFold": 2
             }
         },
         "serverConfig": {