Compare commits

...
3 Commits
4 changed files with 12 additions and 4 deletions
+2 -2
View File
@@ -875,7 +875,7 @@ var policies = {
return offenders;
}
},
/*"unusedUnicodeRanges": {
"unusedUnicodeRanges": {
"tool": "redownload",
"label": "Unused Unicode ranges",
"message": "<p>This metric counts the number of unused Unicode ranges inside each font. For example, one font could include Cyrillic glyphs but none of them are used on the page.</p><p>It also reveals the number of ligatures (letters that are represented differently when close to each other) and hidden chars (glyphs not linked to the unicode system that can't be displayed on the web).</p><p>Because of technical limitations, Yellow Lab Tools checks each font against the glyphs of the entire page. As a result, estimated use is >= to reality. For example, if you read that 10 glyphs are \"possibly used\", it means that these 10 glyphs are used on the page but nothing guaranties that they are displayed using this font.</p><p>Tools such as <a href=\"https://www.fontsquirrel.com/tools/webfont-generator\" target=\"_blank\">Font Squirrel</a> can remove some unicode ranges from a font.</p><p>In the case of an icon font, make sure you only keep the icons that are used on the website and to remove the others. Several tools are able to extract SVG images from a font, then some other tools can generate a font from the SVGs you want to keep.</p>",
@@ -886,7 +886,7 @@ var policies = {
"offendersTransformFn": function(offenders) {
return offenders;
}
},*/
},
"nonWoff2Fonts": {
"tool": "redownload",
"label": "WOFF 2",
+1
View File
@@ -86,6 +86,7 @@
"policies": {
"fontsCount": 1,
"heavyFonts": 0.5,
"unusedUnicodeRanges": 0.5,
"nonWoff2Fonts": 0.5
}
},
+6
View File
@@ -78,6 +78,12 @@ var Runner = function(params) {
milestone: 'redownload'
});
// Fix: don't display Unicode ranges if the module is not present in Phantomas
if (!data.toolsResults.phantomas.metrics.charactersCount) {
delete data.toolsResults.redownload.metrics.unusedUnicodeRanges;
delete data.toolsResults.redownload.offenders.unusedUnicodeRanges;
}
// Rules checker
var policies = require('./metadata/policies');
data.rules = rulesChecker.check(data, policies);
+3 -2
View File
@@ -65,8 +65,8 @@ var Redownload = function() {
// Prevent a bug with the font analyzer on empty pages
var differentCharacters = '';
if (data.toolsResults.phantomas.offenders.differentCharacters && data.toolsResults.phantomas.offenders.differentCharacters.length > 0) {
differentCharacters = data.toolsResults.phantomas.offenders.differentCharacters[0];
if (data.toolsResults.phantomas.offenders.charactersCount && data.toolsResults.phantomas.offenders.charactersCount.length > 0) {
differentCharacters = data.toolsResults.phantomas.offenders.charactersCount[0];
}
// Transform every request into a download function with a callback when done
@@ -900,6 +900,7 @@ var Redownload = function() {
var result = {
bodyBuffer: body,
headersSize: Buffer.byteLength(rawHeaders, 'utf8'),
headers: res.headers,
bodySize: bodySize,
isCompressed: isCompressed,
compressionTool: compressionTool,