Add Gzip offenders

This commit is contained in:
Gaël Métais
2015-06-19 16:16:00 +02:00
parent d166003dfe
commit 53a9aa377a
5 changed files with 29 additions and 8 deletions
+20
View File
@@ -225,6 +225,26 @@
</div>
</div>
<div ng-if="policyName === 'gzipCompression'">
<h3 ng-if="rule.value > 0">{{rule.value | bytes}} could be saved on <ng-pluralize count="rule.offendersObj.list.images.length" when="{'one': '1 file', 'other': '{} files'}"></ng-pluralize></h3>
<div class="table">
<div class="headers">
<div>File</div>
<div>Current weight</div>
<div>Gzipped</div>
<div>Gain</div>
</div>
<div ng-repeat="file in rule.offendersObj.list.files | orderBy:'-gain'">
<div>
<url-link url="file.url" max-length="70"></url-link>
</div>
<div>{{file.original | bytes}}</div>
<div>{{file.gzipped | bytes}}</div>
<div><b>-{{file.gain | bytes}}</b></div>
</div>
</div>
</div>
<div ng-if="policyName === 'fileMinification'">
<h3 ng-if="rule.value > 0">{{rule.value | bytes}} could be saved on <ng-pluralize count="rule.offendersObj.list.files.length" when="{'one': '1 file', 'other': '{} files'}"></ng-pluralize></h3>
<div class="table">
+5 -5
View File
@@ -866,9 +866,9 @@ var policies = {
"tool": "weightChecker",
"label": "Image optimization",
"message": "<p>This metric mesures the number of bytes that could be saved by optimizing images.</p><p>Image optimization is generally one of the easiest way to reduce a page weight, and as a result, the page load time. Don't use Photoshop or other image editing tools, they're not very good for optimization. Use specialized tools such as <a href=\"https://kraken.io/\" target=\"_blank\">Kraken.io</a> or the excellent <a href=\"https://imageoptim.com/\" target=\"_blank\">ImageOption</a> on Mac. For SVG images, you can use <a href=\"https://jakearchibald.github.io/svgomg/\" target=\"_blank\">SVGOMG</a></p><p>The tools in use in YellowLabTools are not set to their maximum optimization power, so you might be able to compress even more!</p>",
"isOkThreshold": 30720,
"isOkThreshold": 10240,
"isBadThreshold": 122880,
"isAbnormalThreshold": 409600,
"isAbnormalThreshold": 307200,
"hasOffenders": true,
"unit": 'bytes'
},
@@ -876,7 +876,7 @@ var policies = {
"tool": "weightChecker",
"label": "Gzip compression",
"message": "<p>Mesures the number of bytes that could be saved by compressing file transfers.</p><p>Gzip is a powerfull weight reducer and should be enabled on text-based assets in your server's configuration. Note that gzipping small files (< 1 KB) is arguable, and that some assets such as images should not be gzipped as they are already compressed. <a href=\"https://gist.github.com/gmetais/971ce13a1fbeebd88445\" target=\"_blank\">Here</a> is a list of Content-Types that should be gzipped.</p>",
"isOkThreshold": 20480,
"isOkThreshold": 5125,
"isBadThreshold": 81920,
"isAbnormalThreshold": 153600,
"hasOffenders": true,
@@ -886,8 +886,8 @@ var policies = {
"tool": "weightChecker",
"label": "File minification",
"message": "<p>This is the weight that could be saved if all text resources were correctly minified.</p><p>The tools in use here are <b>UglifyJS</b>, <b>clean-css</b> and <b>HTMLMinifier</b>. These tools are so good that some of your minified files can be marked as unminified. Change your tool it this happens :)</p><p>The gains of minification are generally small, but the impact can be high when these text files are loaded on the critical path.</p>",
"isOkThreshold": 10240,
"isBadThreshold": 76800,
"isOkThreshold": 5125,
"isBadThreshold": 61440,
"isAbnormalThreshold": 122880,
"hasOffenders": true,
"unit": 'bytes'
+1 -1
View File
@@ -121,7 +121,7 @@ var FileMinifier = function() {
});
} else {
debug('File type %s is not an (optimizable) image', entry.contentType);
debug('Not minfiable type or already minified');
deferred.resolve(entry);
}
@@ -41,6 +41,7 @@ var GzipCompressor = function() {
}
});
} else {
deferred.resolve(entry);
}
+2 -2
View File
@@ -143,7 +143,7 @@ var ImageOptimizer = function() {
});
} else {
debug('File type %s is not an (optimizable) image', entry.contentType);
debug('File type %s is not an optimizable image', entry.contentType);
deferred.resolve(entry);
}
@@ -167,7 +167,7 @@ var ImageOptimizer = function() {
}
function isSVG(entry) {
return entry.isImage && entry.contentType === 'image/svg+xml';
return entry.isImage && entry.isSVG;
}
function compressJpegLosslessly(imageBody) {