diff --git a/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js b/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js index 9d23ae867716..edfc18cc4635 100644 --- a/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js +++ b/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js @@ -179,9 +179,7 @@ module.exports = [ details: { items: { 0: { - 2: { - text: /^480 x 57/, - }, + displayedAspectRatio: /^480 x 57/, }, length: 1, }, diff --git a/lighthouse-cli/test/smokehouse/smokehouse.js b/lighthouse-cli/test/smokehouse/smokehouse.js index 2861cb538c44..407635f800bb 100755 --- a/lighthouse-cli/test/smokehouse/smokehouse.js +++ b/lighthouse-cli/test/smokehouse/smokehouse.js @@ -181,6 +181,13 @@ function collateResults(actual, expected) { throw new Error(`Config did not trigger run of expected audit ${auditName}`); } + // TODO: TERRIBLE HACK, remove asap + // Smokehouse has been asserting the AuditResult.score, whereas report cares about AuditDfn score (within reportCategories) + // A subsequent PR will change scores completely which means rebaselining all our smokehouse expectations + if (actualResult.scoringMode === 'binary') { + actualResult.score = Boolean(actualResult.score); + } + const expectedResult = expected.audits[auditName]; const diff = findDifference(auditName, actualResult, expectedResult); diff --git a/lighthouse-core/audits/audit.js b/lighthouse-core/audits/audit.js index 90ecd29de703..d7134b254f81 100644 --- a/lighthouse-core/audits/audit.js +++ b/lighthouse-core/audits/audit.js @@ -70,54 +70,27 @@ class Audit { }); } - /** - * Table cells will use the type specified in headings[x].itemType. However a custom type - * can be provided: results[x].propName = {type: 'code', text: '...'} - * @param {!Audit.Headings} headings - * @param {!Array>} results - * @return {!Array} - */ - static makeTableRows(headings, results) { - const tableRows = results.map(item => { - return headings.map(heading => { - const value = item[heading.key]; - if (typeof value === 'object' && value && value.type) return value; - - return { - type: heading.itemType, - text: value, - }; - }); - }); - return tableRows; - } - - /** - * @param {!Audit.Headings} headings - * @return {!Array} - */ - static makeTableHeaders(headings) { - return headings.map(heading => ({ - type: 'text', - itemKey: heading.key, - itemType: heading.itemType, - text: heading.text, - })); - } - /** * @param {!Audit.Headings} headings * @param {!Array>} results + * @param {!DetailsRenderer.DetailsSummary} summary * @return {!DetailsRenderer.DetailsJSON} */ - static makeTableDetails(headings, results) { - const tableHeaders = Audit.makeTableHeaders(headings); - const tableRows = Audit.makeTableRows(headings, results); + static makeTableDetails(headings, results, summary) { + if (results.length === 0) { + return { + type: 'table', + headings: [], + items: [], + summary, + }; + } + return { type: 'table', - header: 'View Details', - itemHeaders: tableHeaders, - items: tableRows, + headings: headings, + items: results, + summary, }; } @@ -141,12 +114,27 @@ class Audit { if (displayValue === score) { displayValue = ''; } + + // TODO: restore after initial 3.0 branching + // if (typeof score === 'boolean' || score === null) { + // score = score ? 100 : 0; + // } + + // if (!Number.isFinite(score)) { + // throw new Error(`Invalid score: ${score}`); + // } + + // TODO, don't consider an auditResult's scoringMode (currently applied to all ByteEfficiency) + const scoringMode = result.scoringMode || audit.meta.scoringMode || Audit.SCORING_MODES.BINARY; + delete result.scoringMode; + let auditDescription = audit.meta.description; if (audit.meta.failureDescription) { if (!score || (typeof score === 'number' && score < 100)) { auditDescription = audit.meta.failureDescription; } } + return { score, displayValue: `${displayValue}`, @@ -154,7 +142,7 @@ class Audit { error: result.error, debugString: result.debugString, extendedInfo: result.extendedInfo, - scoringMode: audit.meta.scoringMode || Audit.SCORING_MODES.BINARY, + scoringMode, informative: audit.meta.informative, manual: audit.meta.manual, notApplicable: result.notApplicable, @@ -172,7 +160,6 @@ module.exports = Audit; * @typedef {Object} Audit.Heading * @property {string} key * @property {string} itemType - * @property {string} itemKey * @property {string} text */ diff --git a/lighthouse-core/audits/bootup-time.js b/lighthouse-core/audits/bootup-time.js index d98aa32c417e..16e8aaf5de0a 100644 --- a/lighthouse-core/audits/bootup-time.js +++ b/lighthouse-core/audits/bootup-time.js @@ -95,13 +95,14 @@ class BootupTime extends Audit { .filter(result => result.sum >= THRESHOLD_IN_MS) .sort((a, b) => b.sum - a.sum); - const tableDetails = BootupTime.makeTableDetails(headings, results); + const summary = {wastedMs: totalBootupTime}; + const details = BootupTime.makeTableDetails(headings, results, summary); return { score: totalBootupTime < 2000, rawValue: totalBootupTime, displayValue: Util.formatMilliseconds(totalBootupTime), - details: tableDetails, + details, extendedInfo: { value: extendedInfo, }, diff --git a/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js b/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js index c7085f361156..3fc86a74cd04 100644 --- a/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +++ b/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js @@ -29,16 +29,12 @@ class UnusedBytes extends Audit { } /** + * TODO: REMOVE * @param {number} bytes * @return {string} */ static bytesDetails(bytes) { - return { - type: 'bytes', - value: bytes, - displayUnit: 'kb', - granularity: 1, - }; + return bytes; } /** @@ -46,13 +42,9 @@ class UnusedBytes extends Audit { * @param {number} networkThroughput measured in bytes/second * @return {string} */ - static bytesToMsDetails(bytes, networkThroughput) { + static bytesToMs(bytes, networkThroughput) { const milliseconds = bytes / networkThroughput * 1000; - return { - type: 'ms', - value: milliseconds, - granularity: 10, - }; + return milliseconds; } /** @@ -109,10 +101,8 @@ class UnusedBytes extends Audit { const debugString = result.debugString; const results = result.results .map(item => { - item.wastedKb = this.bytesDetails(item.wastedBytes); - item.wastedMs = this.bytesToMsDetails(item.wastedBytes, networkThroughput); - item.totalKb = this.bytesDetails(item.totalBytes); - item.totalMs = this.bytesToMsDetails(item.totalBytes, networkThroughput); + item.wastedMs = this.bytesToMs(item.wastedBytes, networkThroughput); + item.totalMs = this.bytesToMs(item.totalBytes, networkThroughput); return item; }) .sort((itemA, itemB) => itemB.wastedBytes - itemA.wastedBytes); @@ -126,13 +116,18 @@ class UnusedBytes extends Audit { displayValue = `Potential savings of ${wastedBytes} bytes`; } - const tableDetails = Audit.makeTableDetails(result.headings, results); + const summary = { + wastedMs, + wastedBytes, + }; + const details = Audit.makeTableDetails(result.headings, results, summary); return { debugString, displayValue, rawValue: wastedMs, score: UnusedBytes.scoreForWastedMs(wastedMs), + scoringMode: Audit.SCORING_MODES.NUMERIC, extendedInfo: { value: { wastedMs, @@ -140,7 +135,7 @@ class UnusedBytes extends Audit { results, }, }, - details: tableDetails, + details, }; } diff --git a/lighthouse-core/audits/byte-efficiency/offscreen-images.js b/lighthouse-core/audits/byte-efficiency/offscreen-images.js index 337e1052e5ae..a874a7edb892 100644 --- a/lighthouse-core/audits/byte-efficiency/offscreen-images.js +++ b/lighthouse-core/audits/byte-efficiency/offscreen-images.js @@ -28,7 +28,8 @@ class OffscreenImages extends ByteEfficiencyAudit { name: 'offscreen-images', description: 'Offscreen images', informative: true, - helpText: 'Consider lazy-loading offscreen and hidden images to improve page load speed ' + + helpText: + 'Consider lazy-loading offscreen and hidden images to improve page load speed ' + 'and time to interactive. ' + '[Learn more](https://developers.google.com/web/tools/lighthouse/audits/offscreen-images).', requiredArtifacts: ['ImageUsage', 'ViewportDimensions', 'traces', 'devtoolsLogs'], @@ -72,11 +73,6 @@ class OffscreenImages extends ByteEfficiencyAudit { return { url, - preview: { - type: 'thumbnail', - url: image.networkRecord.url, - mimeType: image.networkRecord.mimeType, - }, requestStartTime: image.networkRecord.startTime, totalBytes, wastedBytes, @@ -107,9 +103,9 @@ class OffscreenImages extends ByteEfficiencyAudit { } // If an image was used more than once, warn only about its least wasteful usage - const existing = results.get(processed.preview.url); + const existing = results.get(processed.url); if (!existing || existing.wastedBytes > processed.wastedBytes) { - results.set(processed.preview.url, processed); + results.set(processed.url, processed); } return results; @@ -118,17 +114,24 @@ class OffscreenImages extends ByteEfficiencyAudit { return artifacts.requestFirstInteractive(trace).then(firstInteractive => { const ttiTimestamp = firstInteractive.timestamp / 1000000; const results = Array.from(resultsMap.values()).filter(item => { - const isWasteful = item.wastedBytes > IGNORE_THRESHOLD_IN_BYTES && - item.wastedPercent > IGNORE_THRESHOLD_IN_PERCENT; + const isWasteful = + item.wastedBytes > IGNORE_THRESHOLD_IN_BYTES && + item.wastedPercent > IGNORE_THRESHOLD_IN_PERCENT; const loadedEarly = item.requestStartTime < ttiTimestamp; return isWasteful && loadedEarly; }); const headings = [ - {key: 'preview', itemType: 'thumbnail', text: ''}, + {key: 'url', itemType: 'thumbnail', text: ''}, {key: 'url', itemType: 'url', text: 'URL'}, - {key: 'totalKb', itemType: 'text', text: 'Original'}, - {key: 'wastedKb', itemType: 'text', text: 'Potential Savings'}, + {key: 'totalBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, text: 'Original'}, + { + key: 'wastedBytes', + itemType: 'bytes', + displayUnit: 'kb', + granularity: 1, + text: 'Potential Savings', + }, ]; return { diff --git a/lighthouse-core/audits/byte-efficiency/total-byte-weight.js b/lighthouse-core/audits/byte-efficiency/total-byte-weight.js index cf90b7bf6b39..407f77e0fa03 100644 --- a/lighthouse-core/audits/byte-efficiency/total-byte-weight.js +++ b/lighthouse-core/audits/byte-efficiency/total-byte-weight.js @@ -6,6 +6,7 @@ 'use strict'; const ByteEfficiencyAudit = require('./byte-efficiency-audit'); +const Util = require('../../report/v2/renderer/util'); // Parameters for log-normal CDF scoring. See https://www.desmos.com/calculator/gpmjeykbwr // ~75th and ~90th percentiles http://httparchive.org/interesting.php?a=All&l=Feb%201%202017&s=All#bytesTotal @@ -22,9 +23,9 @@ class TotalByteWeight extends ByteEfficiencyAudit { description: 'Avoids enormous network payloads', failureDescription: 'Has enormous network payloads', helpText: - 'Large network payloads cost users real money and are highly correlated with ' + - 'long load times. [Learn ' + - 'more](https://developers.google.com/web/tools/lighthouse/audits/network-payloads).', + 'Large network payloads cost users real money and are highly correlated with ' + + 'long load times. [Learn ' + + 'more](https://developers.google.com/web/tools/lighthouse/audits/network-payloads).', scoringMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC, requiredArtifacts: ['devtoolsLogs'], }; @@ -50,8 +51,7 @@ class TotalByteWeight extends ByteEfficiencyAudit { const result = { url: record.url, totalBytes: record.transferSize, - totalKb: ByteEfficiencyAudit.bytesDetails(record.transferSize), - totalMs: ByteEfficiencyAudit.bytesToMsDetails(record.transferSize, networkThroughput), + totalMs: ByteEfficiencyAudit.bytesToMs(record.transferSize, networkThroughput), }; totalBytes += result.totalBytes; @@ -60,7 +60,6 @@ class TotalByteWeight extends ByteEfficiencyAudit { const totalCompletedRequests = results.length; results = results.sort((itemA, itemB) => itemB.totalBytes - itemA.totalBytes).slice(0, 10); - // Use the CDF of a log-normal distribution for scoring. // <= 1600KB: score≈100 // 4000KB: score=50 @@ -73,8 +72,14 @@ class TotalByteWeight extends ByteEfficiencyAudit { const headings = [ {key: 'url', itemType: 'url', text: 'URL'}, - {key: 'totalKb', itemType: 'text', text: 'Total Size'}, - {key: 'totalMs', itemType: 'text', text: 'Transfer Time'}, + { + key: 'totalBytes', + itemType: 'bytes', + displayUnit: 'kb', + granularity: 1, + text: 'Total Size', + }, + {key: 'totalMs', itemType: 'ms', text: 'Transfer Time'}, ]; const tableDetails = ByteEfficiencyAudit.makeTableDetails(headings, results); @@ -82,7 +87,7 @@ class TotalByteWeight extends ByteEfficiencyAudit { return { score, rawValue: totalBytes, - displayValue: `Total size was ${Math.round(totalBytes / 1024)} KB`, + displayValue: `Total size was ${Util.formatBytesToKB(totalBytes, 1)}`, extendedInfo: { value: { results, diff --git a/lighthouse-core/audits/byte-efficiency/unminified-css.js b/lighthouse-core/audits/byte-efficiency/unminified-css.js index 35dfff8d2061..220de0646a8f 100644 --- a/lighthouse-core/audits/byte-efficiency/unminified-css.js +++ b/lighthouse-core/audits/byte-efficiency/unminified-css.js @@ -103,7 +103,7 @@ class UnminifiedCSS extends ByteEfficiencyAudit { let url = stylesheet.header.sourceURL; if (!url || url === pageUrl) { const contentPreview = UnusedCSSRules.determineContentPreview(stylesheet.content); - url = {type: 'code', text: contentPreview}; + url = {type: 'code', value: contentPreview}; } const totalBytes = ByteEfficiencyAudit.estimateTransferSize(networkRecord, content.length, @@ -144,8 +144,9 @@ class UnminifiedCSS extends ByteEfficiencyAudit { results, headings: [ {key: 'url', itemType: 'url', text: 'URL'}, - {key: 'totalKb', itemType: 'text', text: 'Original'}, - {key: 'wastedKb', itemType: 'text', text: 'Potential Savings'}, + {key: 'totalBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, text: 'Original'}, + {key: 'wastedBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, + text: 'Potential Savings'}, ], }; } diff --git a/lighthouse-core/audits/byte-efficiency/unminified-javascript.js b/lighthouse-core/audits/byte-efficiency/unminified-javascript.js index 07703761185b..9a71397d81c4 100644 --- a/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +++ b/lighthouse-core/audits/byte-efficiency/unminified-javascript.js @@ -95,8 +95,9 @@ class UnminifiedJavaScript extends ByteEfficiencyAudit { debugString, headings: [ {key: 'url', itemType: 'url', text: 'URL'}, - {key: 'totalKb', itemType: 'text', text: 'Original'}, - {key: 'wastedKb', itemType: 'text', text: 'Potential Savings'}, + {key: 'totalBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, text: 'Original'}, + {key: 'wastedBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, + text: 'Potential Savings'}, ], }; } diff --git a/lighthouse-core/audits/byte-efficiency/unused-css-rules.js b/lighthouse-core/audits/byte-efficiency/unused-css-rules.js index f78770f1ad1d..68ed1033c0a4 100644 --- a/lighthouse-core/audits/byte-efficiency/unused-css-rules.js +++ b/lighthouse-core/audits/byte-efficiency/unused-css-rules.js @@ -139,7 +139,7 @@ class UnusedCSSRules extends ByteEfficiencyAudit { let url = stylesheetInfo.header.sourceURL; if (!url || url === pageUrl) { const contentPreview = UnusedCSSRules.determineContentPreview(stylesheetInfo.content); - url = {type: 'code', text: contentPreview}; + url = {type: 'code', value: contentPreview}; } const usage = UnusedCSSRules.computeUsage(stylesheetInfo); @@ -166,8 +166,9 @@ class UnusedCSSRules extends ByteEfficiencyAudit { const headings = [ {key: 'url', itemType: 'url', text: 'URL'}, - {key: 'totalKb', itemType: 'text', text: 'Original'}, - {key: 'wastedKb', itemType: 'text', text: 'Potential Savings'}, + {key: 'totalBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, text: 'Original'}, + {key: 'wastedBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, + text: 'Potential Savings'}, ]; return { diff --git a/lighthouse-core/audits/byte-efficiency/unused-javascript.js b/lighthouse-core/audits/byte-efficiency/unused-javascript.js index d9572d39b122..cf6fd07a39b9 100644 --- a/lighthouse-core/audits/byte-efficiency/unused-javascript.js +++ b/lighthouse-core/audits/byte-efficiency/unused-javascript.js @@ -111,8 +111,9 @@ class UnusedJavaScript extends ByteEfficiencyAudit { results, headings: [ {key: 'url', itemType: 'url', text: 'URL'}, - {key: 'totalKb', itemType: 'text', text: 'Original'}, - {key: 'wastedKb', itemType: 'text', text: 'Potential Savings'}, + {key: 'totalBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, text: 'Original'}, + {key: 'wastedBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, + text: 'Potential Savings'}, ], }; } diff --git a/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js b/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js index 9a40d9cdb318..8d8718252d7a 100644 --- a/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js +++ b/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js @@ -7,6 +7,7 @@ const assert = require('assert'); const parseCacheControl = require('parse-cache-control'); +const Audit = require('../audit'); const ByteEfficiencyAudit = require('./byte-efficiency-audit'); const WebInspector = require('../../lib/web-inspector'); const URL = require('../../lib/url-shim'); @@ -18,7 +19,7 @@ const IGNORE_THRESHOLD_IN_PERCENT = 0.925; const SCORING_POINT_OF_DIMINISHING_RETURNS = 4; // 4 KB const SCORING_MEDIAN = 768; // 768 KB -class CacheHeaders extends ByteEfficiencyAudit { +class CacheHeaders extends Audit { /** * @return {!AuditMeta} */ @@ -186,13 +187,7 @@ class CacheHeaders extends ByteEfficiencyAudit { const url = URL.elideDataURI(record._url); const totalBytes = record._transferSize; - const totalKb = ByteEfficiencyAudit.bytesDetails(totalBytes); const wastedBytes = (1 - cacheHitProbability) * totalBytes; - const cacheLifetimeDisplay = { - type: 'ms', - value: cacheLifetimeInSeconds, - displayUnit: 'duration', - }; totalWastedBytes += wastedBytes; if (url.includes('?')) queryStringCount++; @@ -201,9 +196,7 @@ class CacheHeaders extends ByteEfficiencyAudit { url, cacheControl, cacheLifetimeInSeconds, - cacheLifetimeDisplay, cacheHitProbability, - totalKb, totalBytes, wastedBytes, }); @@ -225,11 +218,13 @@ class CacheHeaders extends ByteEfficiencyAudit { const headings = [ {key: 'url', itemType: 'url', text: 'URL'}, - {key: 'cacheLifetimeDisplay', itemType: 'text', text: 'Cache TTL'}, - {key: 'totalKb', itemType: 'text', text: 'Size (KB)'}, + {key: 'cacheLifetimeInSeconds', itemType: 'ms', text: 'Cache TTL', displayUnit: 'duration'}, + {key: 'totalBytes', itemType: 'bytes', text: 'Size (KB)', displayUnit: 'kb', + granularity: 1}, ]; - const tableDetails = ByteEfficiencyAudit.makeTableDetails(headings, results); + const summary = {wastedBytes: totalWastedBytes}; + const details = ByteEfficiencyAudit.makeTableDetails(headings, results, summary); return { score, @@ -241,7 +236,7 @@ class CacheHeaders extends ByteEfficiencyAudit { queryStringCount, }, }, - details: tableDetails, + details, }; }); } diff --git a/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js b/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js index 3d5359c23626..2aff63451945 100644 --- a/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js +++ b/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js @@ -65,7 +65,6 @@ class UsesOptimizedImages extends ByteEfficiencyAudit { url, fromProtocol: image.fromProtocol, isCrossOrigin: !image.isSameOrigin, - preview: {url: image.url, mimeType: image.mimeType, type: 'thumbnail'}, totalBytes: image.originalSize, wastedBytes: jpegSavings.bytes, }); @@ -78,10 +77,11 @@ class UsesOptimizedImages extends ByteEfficiencyAudit { } const headings = [ - {key: 'preview', itemType: 'thumbnail', text: ''}, + {key: 'url', itemType: 'thumbnail', text: ''}, {key: 'url', itemType: 'url', text: 'URL'}, - {key: 'totalKb', itemType: 'text', text: 'Original'}, - {key: 'wastedKb', itemType: 'text', text: 'Potential Savings'}, + {key: 'totalBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, text: 'Original'}, + {key: 'wastedBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, + text: 'Potential Savings'}, ]; return { diff --git a/lighthouse-core/audits/byte-efficiency/uses-request-compression.js b/lighthouse-core/audits/byte-efficiency/uses-request-compression.js index c48371f7aeee..60bb718a3a56 100644 --- a/lighthouse-core/audits/byte-efficiency/uses-request-compression.js +++ b/lighthouse-core/audits/byte-efficiency/uses-request-compression.js @@ -71,8 +71,9 @@ class ResponsesAreCompressed extends ByteEfficiencyAudit { const headings = [ {key: 'url', itemType: 'url', text: 'Uncompressed resource URL'}, - {key: 'totalKb', itemType: 'text', text: 'Original'}, - {key: 'wastedKb', itemType: 'text', text: 'GZIP Savings'}, + {key: 'totalBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, text: 'Original'}, + {key: 'wastedBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, + text: 'GZIP Savings'}, ]; return { diff --git a/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js b/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js index 2883be8408e9..cd6c0ddabb2d 100644 --- a/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +++ b/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js @@ -62,11 +62,6 @@ class UsesResponsiveImages extends ByteEfficiencyAudit { return { url, - preview: { - type: 'thumbnail', - url: image.networkRecord.url, - mimeType: image.networkRecord.mimeType, - }, totalBytes, wastedBytes, wastedPercent: 100 * wastedRatio, @@ -100,9 +95,9 @@ class UsesResponsiveImages extends ByteEfficiencyAudit { } // Don't warn about an image that was later used appropriately - const existing = resultsMap.get(processed.preview.url); + const existing = resultsMap.get(processed.url); if (!existing || existing.wastedBytes > processed.wastedBytes) { - resultsMap.set(processed.preview.url, processed); + resultsMap.set(processed.url, processed); } }); @@ -110,10 +105,11 @@ class UsesResponsiveImages extends ByteEfficiencyAudit { .filter(item => item.wastedBytes > IGNORE_THRESHOLD_IN_BYTES); const headings = [ - {key: 'preview', itemType: 'thumbnail', text: ''}, + {key: 'url', itemType: 'thumbnail', text: ''}, {key: 'url', itemType: 'url', text: 'URL'}, - {key: 'totalKb', itemType: 'text', text: 'Original'}, - {key: 'wastedKb', itemType: 'text', text: 'Potential Savings'}, + {key: 'totalBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, text: 'Original'}, + {key: 'wastedBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, + text: 'Potential Savings'}, ]; return { diff --git a/lighthouse-core/audits/byte-efficiency/uses-webp-images.js b/lighthouse-core/audits/byte-efficiency/uses-webp-images.js index 97f53caec286..ad5b6a8d991d 100644 --- a/lighthouse-core/audits/byte-efficiency/uses-webp-images.js +++ b/lighthouse-core/audits/byte-efficiency/uses-webp-images.js @@ -54,7 +54,6 @@ class UsesWebPImages extends ByteEfficiencyAudit { url, fromProtocol: image.fromProtocol, isCrossOrigin: !image.isSameOrigin, - preview: {url: image.url, mimeType: image.mimeType, type: 'thumbnail'}, totalBytes: image.originalSize, wastedBytes: webpSavings.bytes, }); @@ -67,10 +66,11 @@ class UsesWebPImages extends ByteEfficiencyAudit { } const headings = [ - {key: 'preview', itemType: 'thumbnail', text: ''}, + {key: 'url', itemType: 'thumbnail', text: ''}, {key: 'url', itemType: 'url', text: 'URL'}, - {key: 'totalKb', itemType: 'text', text: 'Original'}, - {key: 'wastedKb', itemType: 'text', text: 'Potential Savings'}, + {key: 'totalBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, text: 'Original'}, + {key: 'wastedBytes', itemType: 'bytes', displayUnit: 'kb', granularity: 1, + text: 'Potential Savings'}, ]; return { diff --git a/lighthouse-core/audits/deprecations.js b/lighthouse-core/audits/deprecations.js index 63c77d0d5c01..99df0d6d190e 100644 --- a/lighthouse-core/audits/deprecations.js +++ b/lighthouse-core/audits/deprecations.js @@ -38,16 +38,15 @@ class Deprecations extends Audit { const deprecations = entries.filter(log => log.entry.source === 'deprecation').map(log => { return { - type: 'code', - text: log.entry.text, - url: log.entry.url, + value: log.entry.text, + url: log.entry.url || '', source: log.entry.source, lineNumber: log.entry.lineNumber, }; }); const headings = [ - {key: 'text', itemType: 'code', text: 'Deprecation / Warning'}, + {key: 'value', itemType: 'code', text: 'Deprecation / Warning'}, {key: 'url', itemType: 'url', text: 'URL'}, {key: 'lineNumber', itemType: 'text', text: 'Line'}, ]; diff --git a/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js b/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js index 9b7907004f02..921f3e459e79 100644 --- a/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js +++ b/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js @@ -29,6 +29,7 @@ class LinkBlockingFirstPaintAudit extends Audit { name: 'link-blocking-first-paint', description: 'Reduce render-blocking stylesheets', informative: true, + scoringMode: Audit.SCORING_MODES.NUMERIC, helpText: 'External stylesheets are blocking the first paint of your page. Consider ' + 'delivering critical CSS via `