From 29b340934f04fd331c49aada050974b4cd1e95cb Mon Sep 17 00:00:00 2001 From: Patrick Hulce Date: Thu, 19 Apr 2018 10:44:50 -0700 Subject: [PATCH 1/5] core: merge render blocking audits to lantern --- lighthouse-cli/test/smokehouse/dbw-config.js | 3 +- .../dobetterweb/dbw-expectations.js | 28 +-- .../test/smokehouse/offline-config.js | 3 +- .../offline-local/offline-expectations.js | 5 +- .../byte-efficiency/byte-efficiency-audit.js | 3 +- .../dobetterweb/link-blocking-first-paint.js | 120 ------------- .../dobetterweb/render-blocking-resources.js | 170 ++++++++++++++++++ .../script-blocking-first-paint.js | 46 ----- lighthouse-core/config/default-config.js | 6 +- .../gather/computed/metrics/lantern-metric.js | 5 +- .../lib/dependency-graph/network-node.js | 5 +- .../byte-efficiency-audit-test.js | 27 +++ .../link-blocking-first-paint-test.js | 89 --------- .../render-blocking-resources-test.js | 83 +++++++++ .../script-blocking-first-paint-test.js | 72 -------- 15 files changed, 296 insertions(+), 369 deletions(-) delete mode 100644 lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js create mode 100644 lighthouse-core/audits/dobetterweb/render-blocking-resources.js delete mode 100644 lighthouse-core/audits/dobetterweb/script-blocking-first-paint.js delete mode 100644 lighthouse-core/test/audits/dobetterweb/link-blocking-first-paint-test.js create mode 100644 lighthouse-core/test/audits/dobetterweb/render-blocking-resources-test.js delete mode 100644 lighthouse-core/test/audits/dobetterweb/script-blocking-first-paint-test.js diff --git a/lighthouse-cli/test/smokehouse/dbw-config.js b/lighthouse-cli/test/smokehouse/dbw-config.js index 2bd795cfdea8..4f98d07e94c1 100644 --- a/lighthouse-cli/test/smokehouse/dbw-config.js +++ b/lighthouse-cli/test/smokehouse/dbw-config.js @@ -16,8 +16,7 @@ module.exports = { ], onlyAudits: [ 'dom-size', - 'link-blocking-first-paint', - 'script-blocking-first-paint', + 'render-blocking-resources', 'errors-in-console', ], }, diff --git a/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js b/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js index bec4bbb19801..f51764d97b96 100644 --- a/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js +++ b/lighthouse-cli/test/smokehouse/dobetterweb/dbw-expectations.js @@ -67,22 +67,6 @@ module.exports = [ 'geolocation-on-start': { score: 0, }, - 'link-blocking-first-paint': { - score: 0, - rawValue: '<3000', - extendedInfo: { - value: { - results: { - length: 5, - }, - }, - }, - details: { - items: { - length: 5, - }, - }, - }, 'no-document-write': { score: 0, extendedInfo: { @@ -126,18 +110,12 @@ module.exports = [ 'notification-on-start': { score: 0, }, - 'script-blocking-first-paint': { + 'render-blocking-resources': { score: '<1', - extendedInfo: { - value: { - results: { - length: 2, - }, - }, - }, + rawValue: '>100', details: { items: { - length: 2, + length: 7, }, }, }, diff --git a/lighthouse-cli/test/smokehouse/offline-config.js b/lighthouse-cli/test/smokehouse/offline-config.js index 982ea0973edb..01a263ae96e2 100644 --- a/lighthouse-cli/test/smokehouse/offline-config.js +++ b/lighthouse-cli/test/smokehouse/offline-config.js @@ -23,8 +23,7 @@ module.exports = { 'without-javascript', 'user-timings', 'critical-request-chains', - 'link-blocking-first-paint', - 'script-blocking-first-paint', + 'render-blocking-resources', 'webapp-install-banner', 'splash-screen', 'themed-omnibox', diff --git a/lighthouse-cli/test/smokehouse/offline-local/offline-expectations.js b/lighthouse-cli/test/smokehouse/offline-local/offline-expectations.js index 63f7c9a4f049..2866857a0d4e 100644 --- a/lighthouse-cli/test/smokehouse/offline-local/offline-expectations.js +++ b/lighthouse-cli/test/smokehouse/offline-local/offline-expectations.js @@ -30,7 +30,7 @@ module.exports = [ 'geolocation-on-start': { score: 1, }, - 'link-blocking-first-paint': { + 'render-blocking-resources': { score: 1, }, 'no-document-write': { @@ -42,9 +42,6 @@ module.exports = [ 'no-websql': { score: 1, }, - 'script-blocking-first-paint': { - score: 1, - }, 'uses-passive-event-listeners': { score: 1, }, diff --git a/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js b/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js index 03171611ef6d..9e7a1519db6e 100644 --- a/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +++ b/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js @@ -78,8 +78,7 @@ class UnusedBytes extends Audit { const settings = context && context.settings || {}; const simulatorOptions = { devtoolsLog, - throttlingMethod: settings.throttlingMethod, - throttling: settings.throttling, + settings, }; return artifacts diff --git a/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js b/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js deleted file mode 100644 index 6deecbd6dd66..000000000000 --- a/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @license Copyright 2016 Google Inc. All Rights Reserved. - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - */ - -/** - * @fileoverview Audit a page to see if it does not use that block first paint. - */ - -'use strict'; - -const Audit = require('../audit'); -const Util = require('../../report/v2/renderer/util.js'); -const ByteEfficiencyAudit = require('../byte-efficiency/byte-efficiency-audit'); - -// Because of the way we detect blocking stylesheets, asynchronously loaded -// CSS with link[rel=preload] and an onload handler (see https://github.com/filamentgroup/loadCSS) -// can be falsely flagged as blocking. Therefore, ignore stylesheets that loaded fast enough -// to possibly be non-blocking (and they have minimal impact anyway). -const LOAD_THRESHOLD_IN_MS = 50; - -class LinkBlockingFirstPaintAudit extends Audit { - /** - * @return {!AuditMeta} - */ - static get meta() { - return { - name: 'link-blocking-first-paint', - description: 'Reduce render-blocking stylesheets', - informative: true, - scoreDisplayMode: Audit.SCORING_MODES.NUMERIC, - helpText: 'External stylesheets are blocking the first paint of your page. Consider ' + - 'delivering critical CSS via `