From d70939c2603e8eae5ae3e090b622b4e4738d4ab1 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Tue, 30 Jul 2019 15:54:40 -0500 Subject: [PATCH 1/7] core(third-party-summary): add blocking time impact --- lighthouse-core/audits/third-party-summary.js | 56 +++++++++++-------- lighthouse-core/lib/i18n/locales/en-US.json | 11 ++-- lighthouse-core/lib/i18n/locales/en-XL.json | 11 ++-- .../test/audits/third-party-summary-test.js | 8 ++- lighthouse-core/test/results/sample_v2.json | 21 +++---- proto/sample_v2_round_trip.json | 15 ++--- 6 files changed, 73 insertions(+), 49 deletions(-) diff --git a/lighthouse-core/audits/third-party-summary.js b/lighthouse-core/audits/third-party-summary.js index e63ed31124b4..62c310335d92 100644 --- a/lighthouse-core/audits/third-party-summary.js +++ b/lighthouse-core/audits/third-party-summary.js @@ -14,25 +14,27 @@ const NetworkRecords = require('../computed/network-records.js'); const MainThreadTasks = require('../computed/main-thread-tasks.js'); const UIStrings = { - /** Title of a Lighthouse audit that identifies the code on the page that the user doesn't control. This is shown in a list of audits that Lighthouse generates. */ - title: 'Third-Party Usage', + /** Title of a diagnostic audit that provides detail on the code on the page that the user doesn't control (referred to as "third-party code"). This descriptive title is shown to users when the amount is acceptable and no user action is required. */ + title: 'Third-Party usage', + /** Title of a diagnostic audit that provides detail on the code on the page that the user doesn't control (referred to as "third-party code"). This imperative title is shown to users when there is a significant amount of third-party execution time that should be reduced. */ + failureTitle: 'Reduce impact of third-parties', /** Description of a Lighthouse audit that identifies the code on the page that the user doesn't control. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ description: 'Third-party code can significantly impact load performance. ' + 'Limit the number of redundant third-party providers and try to load third-party code after ' + 'your page has primarily finished loading. [Learn more](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/).', /** Label for a table column that displays the name of a third-party provider that potentially links to their website. */ columnThirdParty: 'Third-Party', - /** Label for a table column that displays how much time each row spent executing on the main thread, entries will be the number of milliseconds spent. */ - columnMainThreadTime: 'Main Thread Time', + /** Label for a table column that displays how much time each row spent blocking other work on the main thread, entries will be the number of milliseconds spent. */ + columnBlockingTime: 'Blocking Time', /** Summary text for the result of a Lighthouse audit that identifies the code on the page that the user doesn't control. This text summarizes the number of distinct entities that were found on the page. */ - displayValue: `{itemCount, plural, - =1 {1 Third-Party Found} - other {# Third-Parties Found} - }`, + displayValue: `Increased Total Blocking Time by {timeInMs, number, milliseconds}\xa0ms`, }; const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); +// A page passes when all third-party code blocks for less than 250 ms. +const PASS_THRESHOLD_IN_MS = 250; + /** @typedef {import("third-party-web").IEntity} ThirdPartyEntity */ class ThirdPartySummary extends Audit { @@ -43,8 +45,8 @@ class ThirdPartySummary extends Audit { return { id: 'third-party-summary', title: str_(UIStrings.title), + failureTitle: str_(UIStrings.failureTitle), description: str_(UIStrings.description), - scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE, requiredArtifacts: ['traces', 'devtoolsLogs'], }; } @@ -69,17 +71,18 @@ class ThirdPartySummary extends Audit { * @param {Array} networkRecords * @param {Array} mainThreadTasks * @param {number} cpuMultiplier - * @return {Map} + * @return {Map} */ static getSummaryByEntity(networkRecords, mainThreadTasks, cpuMultiplier) { - /** @type {Map} */ + /** @type {Map} */ const entities = new Map(); + const defaultEntityStat = {mainThreadTime: 0, blockingTime: 0, transferSize: 0}; for (const request of networkRecords) { const entity = ThirdPartySummary.getEntitySafe(request.url); if (!entity) continue; - const entityStats = entities.get(entity) || {mainThreadTime: 0, transferSize: 0}; + const entityStats = entities.get(entity) || {...defaultEntityStat}; entityStats.transferSize += request.transferSize; entities.set(entity, entityStats); } @@ -91,8 +94,14 @@ class ThirdPartySummary extends Audit { const entity = ThirdPartySummary.getEntitySafe(attributeableURL); if (!entity) continue; - const entityStats = entities.get(entity) || {mainThreadTime: 0, transferSize: 0}; - entityStats.mainThreadTime += task.selfTime * cpuMultiplier; + const entityStats = entities.get(entity) || {...defaultEntityStat}; + const taskDuration = task.selfTime * cpuMultiplier; + // The amount of time spent on main thread is the sum of all durations. + entityStats.mainThreadTime += taskDuration; + // The amount of time spent *blocking* on main thread is the sum of all time longer than 50ms. + // Note that this is not totally equivalent to the TBT definition since it fails to account for FCP, + // but a majority of third-party work occurs after FCP and should yield largely similar numbers. + entityStats.blockingTime += Math.max(taskDuration - 50, 0); entities.set(entity, entityStats); } @@ -117,15 +126,15 @@ class ThirdPartySummary extends Audit { const summary = {wastedBytes: 0, wastedMs: 0}; - // Sort by a combined measure of bytes + main thread time. - // 1KB ~= 1 ms - /** @param {{transferSize: number, mainThreadTime: number}} stats */ - const computeSortValue = stats => stats.transferSize / 1024 + stats.mainThreadTime; + // Sort by a combined measure of bytes + blocking time. + // 1.5KB ~= 1 ms + /** @param {{transferSize: number, blockingTime: number}} stats */ + const computeSortValue = stats => stats.transferSize / 1024 + stats.blockingTime * 1.5; const results = Array.from(summaryByEntity.entries()) .map(([entity, stats]) => { summary.wastedBytes += stats.transferSize; - summary.wastedMs += stats.mainThreadTime; + summary.wastedMs += stats.blockingTime; return { entity: /** @type {LH.Audit.Details.LinkValue} */ ({ @@ -135,6 +144,7 @@ class ThirdPartySummary extends Audit { }), transferSize: stats.transferSize, mainThreadTime: stats.mainThreadTime, + blockingTime: stats.blockingTime, }; }) .sort((a, b) => computeSortValue(b) - computeSortValue(a)); @@ -144,8 +154,8 @@ class ThirdPartySummary extends Audit { {key: 'entity', itemType: 'link', text: str_(UIStrings.columnThirdParty)}, {key: 'transferSize', granularity: 1, itemType: 'bytes', text: str_(i18n.UIStrings.columnSize)}, - {key: 'mainThreadTime', granularity: 1, itemType: 'ms', - text: str_(UIStrings.columnMainThreadTime)}, + {key: 'blockingTime', granularity: 1, itemType: 'ms', + text: str_(UIStrings.columnBlockingTime)}, ]; if (!results.length) { @@ -156,8 +166,8 @@ class ThirdPartySummary extends Audit { } return { - score: Number(results.length === 0), - displayValue: str_(UIStrings.displayValue, {itemCount: results.length}), + score: Number(summary.wastedMs <= PASS_THRESHOLD_IN_MS), + displayValue: str_(UIStrings.displayValue, {timeInMs: summary.wastedMs}), details: Audit.makeTableDetails(headings, results, summary), }; } diff --git a/lighthouse-core/lib/i18n/locales/en-US.json b/lighthouse-core/lib/i18n/locales/en-US.json index 7f65c17fd653..318d26523218 100644 --- a/lighthouse-core/lib/i18n/locales/en-US.json +++ b/lighthouse-core/lib/i18n/locales/en-US.json @@ -971,8 +971,8 @@ "lighthouse-core/audits/seo/tap-targets.js | title": { "message": "Tap targets are sized appropriately" }, - "lighthouse-core/audits/third-party-summary.js | columnMainThreadTime": { - "message": "Main Thread Time" + "lighthouse-core/audits/third-party-summary.js | columnBlockingTime": { + "message": "Blocking Time" }, "lighthouse-core/audits/third-party-summary.js | columnThirdParty": { "message": "Third-Party" @@ -981,10 +981,13 @@ "message": "Third-party code can significantly impact load performance. Limit the number of redundant third-party providers and try to load third-party code after your page has primarily finished loading. [Learn more](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/)." }, "lighthouse-core/audits/third-party-summary.js | displayValue": { - "message": "{itemCount, plural,\n =1 {1 Third-Party Found}\n other {# Third-Parties Found}\n }" + "message": "Increased Total Blocking Time by {timeInMs, number, milliseconds} ms" + }, + "lighthouse-core/audits/third-party-summary.js | failureTitle": { + "message": "Reduce impact of third-parties" }, "lighthouse-core/audits/third-party-summary.js | title": { - "message": "Third-Party Usage" + "message": "Third-Party usage" }, "lighthouse-core/audits/time-to-first-byte.js | description": { "message": "Time To First Byte identifies the time at which your server sends a response. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/ttfb)." diff --git a/lighthouse-core/lib/i18n/locales/en-XL.json b/lighthouse-core/lib/i18n/locales/en-XL.json index 4ff4399b076f..851bf25d1f55 100644 --- a/lighthouse-core/lib/i18n/locales/en-XL.json +++ b/lighthouse-core/lib/i18n/locales/en-XL.json @@ -971,8 +971,8 @@ "lighthouse-core/audits/seo/tap-targets.js | title": { "message": "T̂áp̂ t́âŕĝét̂ś âŕê śîźêd́ âṕp̂ŕôṕr̂íât́êĺŷ" }, - "lighthouse-core/audits/third-party-summary.js | columnMainThreadTime": { - "message": "M̂áîń T̂h́r̂éâd́ T̂ím̂é" + "lighthouse-core/audits/third-party-summary.js | columnBlockingTime": { + "message": "B̂ĺôćk̂ín̂ǵ T̂ím̂é" }, "lighthouse-core/audits/third-party-summary.js | columnThirdParty": { "message": "T̂h́îŕd̂-Ṕâŕt̂ý" @@ -981,10 +981,13 @@ "message": "T̂h́îŕd̂-ṕâŕt̂ý ĉód̂é ĉán̂ śîǵn̂íf̂íĉán̂t́l̂ý îḿp̂áĉt́ l̂óâd́ p̂ér̂f́ôŕm̂án̂ćê. Ĺîḿît́ t̂h́ê ńûḿb̂ér̂ óf̂ ŕêd́ûńd̂án̂t́ t̂h́îŕd̂-ṕâŕt̂ý p̂ŕôv́îd́êŕŝ án̂d́ t̂ŕŷ t́ô ĺôád̂ t́ĥír̂d́-p̂ár̂t́ŷ ćôd́ê áf̂t́êŕ ŷóûŕ p̂áĝé ĥáŝ ṕr̂ím̂ár̂íl̂ý f̂ín̂íŝh́êd́ l̂óâd́îńĝ. [Ĺêár̂ń m̂ór̂é](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/)." }, "lighthouse-core/audits/third-party-summary.js | displayValue": { - "message": "{itemCount, plural,\n =1 {1 T̂h́îŕd̂-Ṕâŕt̂ý F̂óûńd̂}\n other {# T́ĥír̂d́-P̂ár̂t́îéŝ F́ôún̂d́}\n }" + "message": "Îńĉŕêáŝéd̂ T́ôt́âĺ B̂ĺôćk̂ín̂ǵ T̂ím̂é b̂ý {timeInMs, number, milliseconds} m̂ś" + }, + "lighthouse-core/audits/third-party-summary.js | failureTitle": { + "message": "R̂éd̂úĉé îḿp̂áĉt́ ôf́ t̂h́îŕd̂-ṕâŕt̂íêś" }, "lighthouse-core/audits/third-party-summary.js | title": { - "message": "T̂h́îŕd̂-Ṕâŕt̂ý Ûśâǵê" + "message": "T̂h́îŕd̂-Ṕâŕt̂ý ûśâǵê" }, "lighthouse-core/audits/time-to-first-byte.js | description": { "message": "T̂ím̂é T̂ó F̂ír̂śt̂ B́ŷt́ê íd̂én̂t́îf́îéŝ t́ĥé t̂ím̂é ât́ ŵh́îćĥ ýôúr̂ śêŕv̂ér̂ śêńd̂ś â ŕêśp̂ón̂śê. [Ĺêár̂ń m̂ór̂é](https://developers.google.com/web/tools/lighthouse/audits/ttfb)." diff --git a/lighthouse-core/test/audits/third-party-summary-test.js b/lighthouse-core/test/audits/third-party-summary-test.js index 7bded94240bb..04c41f017a70 100644 --- a/lighthouse-core/test/audits/third-party-summary-test.js +++ b/lighthouse-core/test/audits/third-party-summary-test.js @@ -22,7 +22,8 @@ describe('Third party summary', () => { const results = await ThirdPartySummary.audit(artifacts, {computedCache: new Map()}); - expect(results.displayValue).toBeDisplayString('2 Third-Parties Found'); + expect(results.score).toBe(1); + expect(results.displayValue).toBeDisplayString('Increased Total Blocking Time by 20 ms'); expect(results.details.items).toEqual([ { entity: { @@ -31,6 +32,7 @@ describe('Third party summary', () => { url: 'https://marketingplatform.google.com/about/tag-manager/', }, mainThreadTime: 104.70300000000002, + blockingTime: 18.186999999999998, transferSize: 30827, }, { @@ -40,6 +42,7 @@ describe('Third party summary', () => { url: 'https://www.google.com/analytics/analytics/', }, mainThreadTime: 87.576, + blockingTime: 0, transferSize: 20913, }, ]); @@ -54,9 +57,12 @@ describe('Third party summary', () => { const settings = {throttlingMethod: 'simulate', throttling: {cpuSlowdownMultiplier: 4}}; const results = await ThirdPartySummary.audit(artifacts, {computedCache: new Map(), settings}); + expect(results.score).toBe(0); expect(results.details.items).toHaveLength(2); expect(Math.round(results.details.items[0].mainThreadTime)).toEqual(419); + expect(Math.round(results.details.items[0].blockingTime)).toEqual(250); expect(Math.round(results.details.items[1].mainThreadTime)).toEqual(350); + expect(Math.round(results.details.items[1].blockingTime)).toEqual(157); }); it('be not applicable when no third parties are present', async () => { diff --git a/lighthouse-core/test/results/sample_v2.json b/lighthouse-core/test/results/sample_v2.json index 9b71f4455959..a0968715754e 100644 --- a/lighthouse-core/test/results/sample_v2.json +++ b/lighthouse-core/test/results/sample_v2.json @@ -1481,11 +1481,11 @@ }, "third-party-summary": { "id": "third-party-summary", - "title": "Third-Party Usage", + "title": "Third-Party usage", "description": "Third-party code can significantly impact load performance. Limit the number of redundant third-party providers and try to load third-party code after your page has primarily finished loading. [Learn more](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/).", - "score": null, - "scoreDisplayMode": "informative", - "displayValue": "1 Third-Party Found", + "score": 1, + "scoreDisplayMode": "binary", + "displayValue": "Increased Total Blocking Time by 20 ms", "details": { "type": "table", "headings": [ @@ -1501,10 +1501,10 @@ "text": "Size" }, { - "key": "mainThreadTime", + "key": "blockingTime", "granularity": 1, "itemType": "ms", - "text": "Main Thread Time" + "text": "Blocking Time" } ], "items": [ @@ -1515,12 +1515,13 @@ "url": "https://developers.google.com/speed/libraries/" }, "transferSize": 30174, - "mainThreadTime": 82.74100000000001 + "mainThreadTime": 82.74100000000001, + "blockingTime": 22.918000000000006 } ], "summary": { "wastedBytes": 30174, - "wastedMs": 82.74100000000001 + "wastedMs": 22.918000000000006 } } }, @@ -5543,7 +5544,7 @@ "lighthouse-core/audits/third-party-summary.js | displayValue": [ { "values": { - "itemCount": 1 + "timeInMs": 22.918000000000006 }, "path": "audits[third-party-summary].displayValue" } @@ -5561,7 +5562,7 @@ "audits[uses-text-compression].details.headings[1].label", "audits[tap-targets].details.headings[1].text" ], - "lighthouse-core/audits/third-party-summary.js | columnMainThreadTime": [ + "lighthouse-core/audits/third-party-summary.js | columnBlockingTime": [ "audits[third-party-summary].details.headings[2].text" ], "lighthouse-core/audits/accessibility/accesskeys.js | title": [ diff --git a/proto/sample_v2_round_trip.json b/proto/sample_v2_round_trip.json index 56dc2663b7ae..8ac28a176274 100644 --- a/proto/sample_v2_round_trip.json +++ b/proto/sample_v2_round_trip.json @@ -2578,12 +2578,13 @@ { "granularity": 1.0, "itemType": "ms", - "key": "mainThreadTime", - "text": "Main Thread Time" + "key": "blockingTime", + "text": "Blocking Time" } ], "items": [ { + "blockingTime": 22.918000000000006, "entity": { "text": "Google CDN", "type": "link", @@ -2595,15 +2596,15 @@ ], "summary": { "wastedBytes": 30174.0, - "wastedMs": 82.74100000000001 + "wastedMs": 22.918000000000006 }, "type": "table" }, - "displayValue": "1 Third-Party Found", + "displayValue": "Increased Total Blocking Time by 20\u00a0ms", "id": "third-party-summary", - "score": null, - "scoreDisplayMode": "informative", - "title": "Third-Party Usage" + "score": 1.0, + "scoreDisplayMode": "binary", + "title": "Third-Party usage" }, "time-to-first-byte": { "description": "Time To First Byte identifies the time at which your server sends a response. [Learn more](https://developers.google.com/web/tools/lighthouse/audits/ttfb).", From e434fd4c5bbd8174071b368cdb8f7cac1d75dbfe Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Wed, 14 Aug 2019 10:22:08 -0500 Subject: [PATCH 2/7] feedbak --- lighthouse-core/audits/third-party-summary.js | 20 ++++++++++--------- lighthouse-core/lib/i18n/locales/en-US.json | 4 ++-- lighthouse-core/lib/i18n/locales/en-XL.json | 4 ++-- lighthouse-core/test/results/sample_v2.json | 5 +++-- proto/sample_v2_round_trip.json | 4 ++-- 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lighthouse-core/audits/third-party-summary.js b/lighthouse-core/audits/third-party-summary.js index 62c310335d92..65d9617c31c3 100644 --- a/lighthouse-core/audits/third-party-summary.js +++ b/lighthouse-core/audits/third-party-summary.js @@ -25,9 +25,12 @@ const UIStrings = { /** Label for a table column that displays the name of a third-party provider that potentially links to their website. */ columnThirdParty: 'Third-Party', /** Label for a table column that displays how much time each row spent blocking other work on the main thread, entries will be the number of milliseconds spent. */ - columnBlockingTime: 'Blocking Time', + columnBlockingTime: 'Main-Thread Blocking Time', /** Summary text for the result of a Lighthouse audit that identifies the code on the page that the user doesn't control. This text summarizes the number of distinct entities that were found on the page. */ - displayValue: `Increased Total Blocking Time by {timeInMs, number, milliseconds}\xa0ms`, + displayValue: `{itemCount, plural, + =1 {1 third-party} + other {# third-parties} + } blocked the main thread by {timeInMs, number, milliseconds}\xa0ms`, }; const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); @@ -126,11 +129,6 @@ class ThirdPartySummary extends Audit { const summary = {wastedBytes: 0, wastedMs: 0}; - // Sort by a combined measure of bytes + blocking time. - // 1.5KB ~= 1 ms - /** @param {{transferSize: number, blockingTime: number}} stats */ - const computeSortValue = stats => stats.transferSize / 1024 + stats.blockingTime * 1.5; - const results = Array.from(summaryByEntity.entries()) .map(([entity, stats]) => { summary.wastedBytes += stats.transferSize; @@ -147,7 +145,8 @@ class ThirdPartySummary extends Audit { blockingTime: stats.blockingTime, }; }) - .sort((a, b) => computeSortValue(b) - computeSortValue(a)); + // Sort by blocking time first, then transfer size to break ties. + .sort((a, b) => (b.blockingTime - a.blockingTime) || (b.transferSize - a.transferSize)); /** @type {LH.Audit.Details.Table['headings']} */ const headings = [ @@ -167,7 +166,10 @@ class ThirdPartySummary extends Audit { return { score: Number(summary.wastedMs <= PASS_THRESHOLD_IN_MS), - displayValue: str_(UIStrings.displayValue, {timeInMs: summary.wastedMs}), + displayValue: str_(UIStrings.displayValue, { + itemCount: results.length, + timeInMs: summary.wastedMs, + }), details: Audit.makeTableDetails(headings, results, summary), }; } diff --git a/lighthouse-core/lib/i18n/locales/en-US.json b/lighthouse-core/lib/i18n/locales/en-US.json index 318d26523218..71a58b869b2e 100644 --- a/lighthouse-core/lib/i18n/locales/en-US.json +++ b/lighthouse-core/lib/i18n/locales/en-US.json @@ -972,7 +972,7 @@ "message": "Tap targets are sized appropriately" }, "lighthouse-core/audits/third-party-summary.js | columnBlockingTime": { - "message": "Blocking Time" + "message": "Main-Thread Blocking Time" }, "lighthouse-core/audits/third-party-summary.js | columnThirdParty": { "message": "Third-Party" @@ -981,7 +981,7 @@ "message": "Third-party code can significantly impact load performance. Limit the number of redundant third-party providers and try to load third-party code after your page has primarily finished loading. [Learn more](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/)." }, "lighthouse-core/audits/third-party-summary.js | displayValue": { - "message": "Increased Total Blocking Time by {timeInMs, number, milliseconds} ms" + "message": "{itemCount, plural,\n =1 {1 third-party}\n other {# third-parties}\n } blocked the main thread by {timeInMs, number, milliseconds} ms" }, "lighthouse-core/audits/third-party-summary.js | failureTitle": { "message": "Reduce impact of third-parties" diff --git a/lighthouse-core/lib/i18n/locales/en-XL.json b/lighthouse-core/lib/i18n/locales/en-XL.json index 851bf25d1f55..3d7d813f1133 100644 --- a/lighthouse-core/lib/i18n/locales/en-XL.json +++ b/lighthouse-core/lib/i18n/locales/en-XL.json @@ -972,7 +972,7 @@ "message": "T̂áp̂ t́âŕĝét̂ś âŕê śîźêd́ âṕp̂ŕôṕr̂íât́êĺŷ" }, "lighthouse-core/audits/third-party-summary.js | columnBlockingTime": { - "message": "B̂ĺôćk̂ín̂ǵ T̂ím̂é" + "message": "M̂áîń-T̂h́r̂éâd́ B̂ĺôćk̂ín̂ǵ T̂ím̂é" }, "lighthouse-core/audits/third-party-summary.js | columnThirdParty": { "message": "T̂h́îŕd̂-Ṕâŕt̂ý" @@ -981,7 +981,7 @@ "message": "T̂h́îŕd̂-ṕâŕt̂ý ĉód̂é ĉán̂ śîǵn̂íf̂íĉán̂t́l̂ý îḿp̂áĉt́ l̂óâd́ p̂ér̂f́ôŕm̂án̂ćê. Ĺîḿît́ t̂h́ê ńûḿb̂ér̂ óf̂ ŕêd́ûńd̂án̂t́ t̂h́îŕd̂-ṕâŕt̂ý p̂ŕôv́îd́êŕŝ án̂d́ t̂ŕŷ t́ô ĺôád̂ t́ĥír̂d́-p̂ár̂t́ŷ ćôd́ê áf̂t́êŕ ŷóûŕ p̂áĝé ĥáŝ ṕr̂ím̂ár̂íl̂ý f̂ín̂íŝh́êd́ l̂óâd́îńĝ. [Ĺêár̂ń m̂ór̂é](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/)." }, "lighthouse-core/audits/third-party-summary.js | displayValue": { - "message": "Îńĉŕêáŝéd̂ T́ôt́âĺ B̂ĺôćk̂ín̂ǵ T̂ím̂é b̂ý {timeInMs, number, milliseconds} m̂ś" + "message": "{itemCount, plural,\n =1 {1 t̂h́îŕd̂-ṕâŕt̂ý}\n other {# t̂h́îŕd̂-ṕâŕt̂íêś}\n } b̂ĺôćk̂éd̂ t́ĥé m̂áîń t̂h́r̂éâd́ b̂ý {timeInMs, number, milliseconds} m̂ś" }, "lighthouse-core/audits/third-party-summary.js | failureTitle": { "message": "R̂éd̂úĉé îḿp̂áĉt́ ôf́ t̂h́îŕd̂-ṕâŕt̂íêś" diff --git a/lighthouse-core/test/results/sample_v2.json b/lighthouse-core/test/results/sample_v2.json index a0968715754e..ebf6b1f2b764 100644 --- a/lighthouse-core/test/results/sample_v2.json +++ b/lighthouse-core/test/results/sample_v2.json @@ -1485,7 +1485,7 @@ "description": "Third-party code can significantly impact load performance. Limit the number of redundant third-party providers and try to load third-party code after your page has primarily finished loading. [Learn more](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/).", "score": 1, "scoreDisplayMode": "binary", - "displayValue": "Increased Total Blocking Time by 20 ms", + "displayValue": "1 third-party blocked the main thread by 20 ms", "details": { "type": "table", "headings": [ @@ -1504,7 +1504,7 @@ "key": "blockingTime", "granularity": 1, "itemType": "ms", - "text": "Blocking Time" + "text": "Main-Thread Blocking Time" } ], "items": [ @@ -5544,6 +5544,7 @@ "lighthouse-core/audits/third-party-summary.js | displayValue": [ { "values": { + "itemCount": 1, "timeInMs": 22.918000000000006 }, "path": "audits[third-party-summary].displayValue" diff --git a/proto/sample_v2_round_trip.json b/proto/sample_v2_round_trip.json index 8ac28a176274..288e2a188e2d 100644 --- a/proto/sample_v2_round_trip.json +++ b/proto/sample_v2_round_trip.json @@ -2579,7 +2579,7 @@ "granularity": 1.0, "itemType": "ms", "key": "blockingTime", - "text": "Blocking Time" + "text": "Main-Thread Blocking Time" } ], "items": [ @@ -2600,7 +2600,7 @@ }, "type": "table" }, - "displayValue": "Increased Total Blocking Time by 20\u00a0ms", + "displayValue": "1 third-party blocked the main thread by 20\u00a0ms", "id": "third-party-summary", "score": 1.0, "scoreDisplayMode": "binary", From 9db995b32e90cf93b5e4497e0f2e8ea96affe433 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Wed, 14 Aug 2019 16:33:19 -0500 Subject: [PATCH 3/7] Apply suggestions from code review Co-Authored-By: Brendan Kenny --- lighthouse-core/audits/third-party-summary.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lighthouse-core/audits/third-party-summary.js b/lighthouse-core/audits/third-party-summary.js index 65d9617c31c3..ba322e1c8e37 100644 --- a/lighthouse-core/audits/third-party-summary.js +++ b/lighthouse-core/audits/third-party-summary.js @@ -14,9 +14,9 @@ const NetworkRecords = require('../computed/network-records.js'); const MainThreadTasks = require('../computed/main-thread-tasks.js'); const UIStrings = { - /** Title of a diagnostic audit that provides detail on the code on the page that the user doesn't control (referred to as "third-party code"). This descriptive title is shown to users when the amount is acceptable and no user action is required. */ + /** Title of a diagnostic audit that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). This descriptive title is shown to users when the amount is acceptable and no user action is required. */ title: 'Third-Party usage', - /** Title of a diagnostic audit that provides detail on the code on the page that the user doesn't control (referred to as "third-party code"). This imperative title is shown to users when there is a significant amount of third-party execution time that should be reduced. */ + /** Title of a diagnostic audit that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). This imperative title is shown to users when there is a significant amount of third-party execution time that should be reduced. */ failureTitle: 'Reduce impact of third-parties', /** Description of a Lighthouse audit that identifies the code on the page that the user doesn't control. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ description: 'Third-party code can significantly impact load performance. ' + @@ -26,7 +26,7 @@ const UIStrings = { columnThirdParty: 'Third-Party', /** Label for a table column that displays how much time each row spent blocking other work on the main thread, entries will be the number of milliseconds spent. */ columnBlockingTime: 'Main-Thread Blocking Time', - /** Summary text for the result of a Lighthouse audit that identifies the code on the page that the user doesn't control. This text summarizes the number of distinct entities that were found on the page. */ + /** Summary text for the result of a Lighthouse audit that identifies the code on a web page that the user doesn't control (referred to as "third-party code"). This text summarizes the number of distinct entities that were found on the page. */ displayValue: `{itemCount, plural, =1 {1 third-party} other {# third-parties} From 782ad1351e74f80e18516b2218bf562f30214d69 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Wed, 14 Aug 2019 16:35:26 -0500 Subject: [PATCH 4/7] display string update --- lighthouse-core/test/audits/third-party-summary-test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lighthouse-core/test/audits/third-party-summary-test.js b/lighthouse-core/test/audits/third-party-summary-test.js index 04c41f017a70..4a8e3cd2e206 100644 --- a/lighthouse-core/test/audits/third-party-summary-test.js +++ b/lighthouse-core/test/audits/third-party-summary-test.js @@ -23,7 +23,9 @@ describe('Third party summary', () => { const results = await ThirdPartySummary.audit(artifacts, {computedCache: new Map()}); expect(results.score).toBe(1); - expect(results.displayValue).toBeDisplayString('Increased Total Blocking Time by 20 ms'); + expect(results.displayValue).toBeDisplayString( + '2 third-parties blocked the main thread by 20 ms' + ); expect(results.details.items).toEqual([ { entity: { From d55a822be2a8a7dcd99349c007f63d3cb14b80c8 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Wed, 14 Aug 2019 20:22:21 -0500 Subject: [PATCH 5/7] shane feedback --- lighthouse-core/audits/third-party-summary.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lighthouse-core/audits/third-party-summary.js b/lighthouse-core/audits/third-party-summary.js index ba322e1c8e37..45413205141b 100644 --- a/lighthouse-core/audits/third-party-summary.js +++ b/lighthouse-core/audits/third-party-summary.js @@ -16,8 +16,8 @@ const MainThreadTasks = require('../computed/main-thread-tasks.js'); const UIStrings = { /** Title of a diagnostic audit that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). This descriptive title is shown to users when the amount is acceptable and no user action is required. */ title: 'Third-Party usage', - /** Title of a diagnostic audit that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). This imperative title is shown to users when there is a significant amount of third-party execution time that should be reduced. */ - failureTitle: 'Reduce impact of third-parties', + /** Title of a diagnostic audit that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). This imperative title is shown to users when there is a significant amount of page execution time caused by third-party code that should be reduced. */ + failureTitle: 'Reduce the impact of third-party code', /** Description of a Lighthouse audit that identifies the code on the page that the user doesn't control. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ description: 'Third-party code can significantly impact load performance. ' + 'Limit the number of redundant third-party providers and try to load third-party code after ' + @@ -27,10 +27,7 @@ const UIStrings = { /** Label for a table column that displays how much time each row spent blocking other work on the main thread, entries will be the number of milliseconds spent. */ columnBlockingTime: 'Main-Thread Blocking Time', /** Summary text for the result of a Lighthouse audit that identifies the code on a web page that the user doesn't control (referred to as "third-party code"). This text summarizes the number of distinct entities that were found on the page. */ - displayValue: `{itemCount, plural, - =1 {1 third-party} - other {# third-parties} - } blocked the main thread by {timeInMs, number, milliseconds}\xa0ms`, + displayValue: `Third-party code blocked the main thread for {timeInMs, number, milliseconds}\xa0ms`, }; const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); From 676b9b06055a91b778694c142e1705eaa8908f2d Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Thu, 15 Aug 2019 14:04:28 -0500 Subject: [PATCH 6/7] sample fixtures --- lighthouse-core/lib/i18n/locales/en-US.json | 4 ++-- lighthouse-core/lib/i18n/locales/en-XL.json | 4 ++-- lighthouse-core/test/results/sample_v2.json | 2 +- proto/sample_v2_round_trip.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lighthouse-core/lib/i18n/locales/en-US.json b/lighthouse-core/lib/i18n/locales/en-US.json index 6199ade05074..6727113c8ed9 100644 --- a/lighthouse-core/lib/i18n/locales/en-US.json +++ b/lighthouse-core/lib/i18n/locales/en-US.json @@ -1083,10 +1083,10 @@ "message": "Third-party code can significantly impact load performance. Limit the number of redundant third-party providers and try to load third-party code after your page has primarily finished loading. [Learn more](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/)." }, "lighthouse-core/audits/third-party-summary.js | displayValue": { - "message": "{itemCount, plural,\n =1 {1 third-party}\n other {# third-parties}\n } blocked the main thread by {timeInMs, number, milliseconds} ms" + "message": "Third-party code blocked the main thread for {timeInMs, number, milliseconds} ms" }, "lighthouse-core/audits/third-party-summary.js | failureTitle": { - "message": "Reduce impact of third-parties" + "message": "Reduce the impact of third-party code" }, "lighthouse-core/audits/third-party-summary.js | title": { "message": "Third-Party usage" diff --git a/lighthouse-core/lib/i18n/locales/en-XL.json b/lighthouse-core/lib/i18n/locales/en-XL.json index 8d77e2f373c0..220fbd3b8e03 100644 --- a/lighthouse-core/lib/i18n/locales/en-XL.json +++ b/lighthouse-core/lib/i18n/locales/en-XL.json @@ -1083,10 +1083,10 @@ "message": "T̂h́îŕd̂-ṕâŕt̂ý ĉód̂é ĉán̂ śîǵn̂íf̂íĉán̂t́l̂ý îḿp̂áĉt́ l̂óâd́ p̂ér̂f́ôŕm̂án̂ćê. Ĺîḿît́ t̂h́ê ńûḿb̂ér̂ óf̂ ŕêd́ûńd̂án̂t́ t̂h́îŕd̂-ṕâŕt̂ý p̂ŕôv́îd́êŕŝ án̂d́ t̂ŕŷ t́ô ĺôád̂ t́ĥír̂d́-p̂ár̂t́ŷ ćôd́ê áf̂t́êŕ ŷóûŕ p̂áĝé ĥáŝ ṕr̂ím̂ár̂íl̂ý f̂ín̂íŝh́êd́ l̂óâd́îńĝ. [Ĺêár̂ń m̂ór̂é](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/)." }, "lighthouse-core/audits/third-party-summary.js | displayValue": { - "message": "{itemCount, plural,\n =1 {1 t̂h́îŕd̂-ṕâŕt̂ý}\n other {# t̂h́îŕd̂-ṕâŕt̂íêś}\n } b̂ĺôćk̂éd̂ t́ĥé m̂áîń t̂h́r̂éâd́ b̂ý {timeInMs, number, milliseconds} m̂ś" + "message": "T̂h́îŕd̂-ṕâŕt̂ý ĉód̂é b̂ĺôćk̂éd̂ t́ĥé m̂áîń t̂h́r̂éâd́ f̂ór̂ {timeInMs, number, milliseconds} ḿŝ" }, "lighthouse-core/audits/third-party-summary.js | failureTitle": { - "message": "R̂éd̂úĉé îḿp̂áĉt́ ôf́ t̂h́îŕd̂-ṕâŕt̂íêś" + "message": "R̂éd̂úĉé t̂h́ê ím̂ṕâćt̂ óf̂ t́ĥír̂d́-p̂ár̂t́ŷ ćôd́ê" }, "lighthouse-core/audits/third-party-summary.js | title": { "message": "T̂h́îŕd̂-Ṕâŕt̂ý ûśâǵê" diff --git a/lighthouse-core/test/results/sample_v2.json b/lighthouse-core/test/results/sample_v2.json index 7a3ab389091d..c5bba298b4d6 100644 --- a/lighthouse-core/test/results/sample_v2.json +++ b/lighthouse-core/test/results/sample_v2.json @@ -1485,7 +1485,7 @@ "description": "Third-party code can significantly impact load performance. Limit the number of redundant third-party providers and try to load third-party code after your page has primarily finished loading. [Learn more](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/).", "score": 1, "scoreDisplayMode": "binary", - "displayValue": "1 third-party blocked the main thread by 20 ms", + "displayValue": "Third-party code blocked the main thread for 20 ms", "details": { "type": "table", "headings": [ diff --git a/proto/sample_v2_round_trip.json b/proto/sample_v2_round_trip.json index 735dba6aa262..b899e7c25df7 100644 --- a/proto/sample_v2_round_trip.json +++ b/proto/sample_v2_round_trip.json @@ -2600,7 +2600,7 @@ }, "type": "table" }, - "displayValue": "1 third-party blocked the main thread by 20\u00a0ms", + "displayValue": "Third-party code blocked the main thread for 20\u00a0ms", "id": "third-party-summary", "score": 1.0, "scoreDisplayMode": "binary", From 9b36046e65e0d30e3ef6f9f3369b61efe9fcd1c1 Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Thu, 15 Aug 2019 16:29:31 -0500 Subject: [PATCH 7/7] tests --- lighthouse-core/audits/third-party-summary.js | 3 ++- lighthouse-core/test/audits/third-party-summary-test.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lighthouse-core/audits/third-party-summary.js b/lighthouse-core/audits/third-party-summary.js index 45413205141b..9aac6184e12c 100644 --- a/lighthouse-core/audits/third-party-summary.js +++ b/lighthouse-core/audits/third-party-summary.js @@ -27,7 +27,8 @@ const UIStrings = { /** Label for a table column that displays how much time each row spent blocking other work on the main thread, entries will be the number of milliseconds spent. */ columnBlockingTime: 'Main-Thread Blocking Time', /** Summary text for the result of a Lighthouse audit that identifies the code on a web page that the user doesn't control (referred to as "third-party code"). This text summarizes the number of distinct entities that were found on the page. */ - displayValue: `Third-party code blocked the main thread for {timeInMs, number, milliseconds}\xa0ms`, + displayValue: 'Third-party code blocked the main thread for ' + + `{timeInMs, number, milliseconds}\xa0ms`, }; const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); diff --git a/lighthouse-core/test/audits/third-party-summary-test.js b/lighthouse-core/test/audits/third-party-summary-test.js index 4a8e3cd2e206..da4c5cacc05d 100644 --- a/lighthouse-core/test/audits/third-party-summary-test.js +++ b/lighthouse-core/test/audits/third-party-summary-test.js @@ -24,7 +24,7 @@ describe('Third party summary', () => { expect(results.score).toBe(1); expect(results.displayValue).toBeDisplayString( - '2 third-parties blocked the main thread by 20 ms' + 'Third-party code blocked the main thread for 20 ms' ); expect(results.details.items).toEqual([ {