misc: rewrite dom-size description (#9821)
This commit is contained in:
Родитель
e9168e7f06
Коммит
90458f8dfc
|
@ -16,20 +16,13 @@ const Audit = require('../audit.js');
|
|||
const Util = require('../../report/html/renderer/util.js');
|
||||
const i18n = require('../../lib/i18n/i18n.js');
|
||||
|
||||
const MAX_DOM_ELEMENTS = 1500;
|
||||
const MAX_DOM_TREE_WIDTH = 60;
|
||||
const MAX_DOM_TREE_DEPTH = 32;
|
||||
|
||||
const UIStrings = {
|
||||
/** Title of a diagnostic audit that provides detail on the size of the web page's DOM. The size of a DOM is characterized by the total number of DOM elements and greatest DOM depth. This descriptive title is shown to users when the amount is acceptable and no user action is required. */
|
||||
title: 'Avoids an excessive DOM size',
|
||||
/** Title of a diagnostic audit that provides detail on the size of the web page's DOM. The size of a DOM is characterized by the total number of DOM elements and greatest DOM depth. This imperative title is shown to users when there is a significant amount of execution time that could be reduced. */
|
||||
failureTitle: 'Avoid an excessive DOM size',
|
||||
/** Description of a Lighthouse audit that tells the user *why* they should reduce the size of the web page's DOM. The size of a DOM is characterized by the total number of DOM elements and greatest DOM depth. 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: 'Browser engineers recommend pages contain fewer than ' +
|
||||
`~${MAX_DOM_ELEMENTS.toLocaleString()} DOM elements. The sweet spot is a tree ` +
|
||||
`depth < ${MAX_DOM_TREE_DEPTH} elements and fewer than ${MAX_DOM_TREE_WIDTH} ` +
|
||||
'children/parent element. A large DOM can increase memory usage, cause longer ' +
|
||||
description: 'A large DOM will increase memory usage, cause longer ' +
|
||||
'[style calculations](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), ' +
|
||||
'and produce costly [layout reflows](https://developers.google.com/speed/articles/reflow). [Learn more](https://web.dev/dom-size).',
|
||||
/** Table column header for the type of statistic. These statistics describe how big the DOM is (count of DOM elements, children, depth). */
|
||||
|
@ -55,10 +48,6 @@ const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|||
|
||||
|
||||
class DOMSize extends Audit {
|
||||
static get MAX_DOM_ELEMENTS() {
|
||||
return MAX_DOM_ELEMENTS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {LH.Audit.Meta}
|
||||
*/
|
||||
|
|
|
@ -522,7 +522,7 @@
|
|||
"message": "Value"
|
||||
},
|
||||
"lighthouse-core/audits/dobetterweb/dom-size.js | description": {
|
||||
"message": "Browser engineers recommend pages contain fewer than ~1,500 DOM elements. The sweet spot is a tree depth < 32 elements and fewer than 60 children/parent element. A large DOM can increase memory usage, cause longer [style calculations](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), and produce costly [layout reflows](https://developers.google.com/speed/articles/reflow). [Learn more](https://web.dev/dom-size)."
|
||||
"message": "A large DOM will increase memory usage, cause longer [style calculations](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), and produce costly [layout reflows](https://developers.google.com/speed/articles/reflow). [Learn more](https://web.dev/dom-size)."
|
||||
},
|
||||
"lighthouse-core/audits/dobetterweb/dom-size.js | displayValue": {
|
||||
"message": "{itemCount, plural,\n =1 {1 element}\n other {# elements}\n }"
|
||||
|
|
|
@ -522,7 +522,7 @@
|
|||
"message": "V̂ál̂úê"
|
||||
},
|
||||
"lighthouse-core/audits/dobetterweb/dom-size.js | description": {
|
||||
"message": "B̂ŕôẃŝér̂ én̂ǵîńêér̂ś r̂éĉóm̂ḿêńd̂ ṕâǵêś ĉón̂t́âín̂ f́êẃêŕ t̂h́âń ~1,500 D̂ÓM̂ él̂ém̂én̂t́ŝ. T́ĥé ŝẃêét̂ śp̂ót̂ íŝ á t̂ŕêé d̂ép̂t́ĥ < 32 él̂ém̂én̂t́ŝ án̂d́ f̂éŵér̂ t́ĥán̂ 60 ćĥíl̂d́r̂én̂/ṕâŕêńt̂ él̂ém̂én̂t́. Â ĺâŕĝé D̂ÓM̂ ćâń îńĉŕêáŝé m̂ém̂ór̂ý ûśâǵê, ćâúŝé l̂ón̂ǵêŕ [ŝt́ŷĺê ćâĺĉúl̂át̂íôńŝ](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), án̂d́ p̂ŕôd́ûćê ćôśt̂ĺŷ [ĺâýôút̂ ŕêf́l̂óŵś](https://developers.google.com/speed/articles/reflow). [L̂éâŕn̂ ḿôŕê](https://web.dev/dom-size)."
|
||||
"message": "Â ĺâŕĝé D̂ÓM̂ ẃîĺl̂ ín̂ćr̂éâśê ḿêḿôŕŷ úŝáĝé, ĉáûśê ĺôńĝér̂ [śt̂ýl̂é ĉál̂ćûĺât́îón̂ś](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), âńd̂ ṕr̂ód̂úĉé ĉóŝt́l̂ý [l̂áŷóût́ r̂éf̂ĺôẃŝ](https://developers.google.com/speed/articles/reflow). [Ĺêár̂ń m̂ór̂é](https://web.dev/dom-size)."
|
||||
},
|
||||
"lighthouse-core/audits/dobetterweb/dom-size.js | displayValue": {
|
||||
"message": "{itemCount, plural,\n =1 {1 êĺêḿêńt̂}\n other {# él̂ém̂én̂t́ŝ}\n }"
|
||||
|
|
|
@ -12,7 +12,7 @@ const options = DOMSize.defaultOptions;
|
|||
/* eslint-env jest */
|
||||
|
||||
describe('DOMSize audit', () => {
|
||||
const numElements = DOMSize.MAX_DOM_ELEMENTS;
|
||||
const numElements = 1500;
|
||||
const artifact = {
|
||||
DOMStats: {
|
||||
totalBodyElements: numElements,
|
||||
|
|
|
@ -2648,7 +2648,7 @@
|
|||
"dom-size": {
|
||||
"id": "dom-size",
|
||||
"title": "Avoids an excessive DOM size",
|
||||
"description": "Browser engineers recommend pages contain fewer than ~1,500 DOM elements. The sweet spot is a tree depth < 32 elements and fewer than 60 children/parent element. A large DOM can increase memory usage, cause longer [style calculations](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), and produce costly [layout reflows](https://developers.google.com/speed/articles/reflow). [Learn more](https://web.dev/dom-size).",
|
||||
"description": "A large DOM will increase memory usage, cause longer [style calculations](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), and produce costly [layout reflows](https://developers.google.com/speed/articles/reflow). [Learn more](https://web.dev/dom-size).",
|
||||
"score": 1,
|
||||
"scoreDisplayMode": "numeric",
|
||||
"numericValue": 31,
|
||||
|
|
|
@ -502,7 +502,7 @@
|
|||
"title": "Document has a `<title>` element"
|
||||
},
|
||||
"dom-size": {
|
||||
"description": "Browser engineers recommend pages contain fewer than ~1,500 DOM elements. The sweet spot is a tree depth < 32 elements and fewer than 60 children/parent element. A large DOM can increase memory usage, cause longer [style calculations](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), and produce costly [layout reflows](https://developers.google.com/speed/articles/reflow). [Learn more](https://web.dev/dom-size).",
|
||||
"description": "A large DOM will increase memory usage, cause longer [style calculations](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), and produce costly [layout reflows](https://developers.google.com/speed/articles/reflow). [Learn more](https://web.dev/dom-size).",
|
||||
"details": {
|
||||
"headings": [
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче