Skip to content

Commit 17d6829

Browse files
build(tooling): widen what the comparisons are measured over
Every fixture so far was source as its author wrote it, which is not the shape most of what a build reads is in. The JavaScript comparison gains minified bundles (jQuery, React DOM and Vue as they ship to production, plus Swagger UI's own bundle), a modern ESM one written in classes and private fields (pdf.js), the smallest module worth timing (Preact) and two more that dwarf the rest (ECharts, Immutable). CSS gains the shapes the framework sheets do not have: an icon font's thousands of one-declaration rules, a sheet that is custom properties and nothing else, and four more component and widget sheets. HTML gains the parts of §13.2 nothing there reached — a document that is all tables, one that leans on every recovery rule the spec writes down, one built out of templates and a declarative shadow root, and an inlined icon sprite for foreign content.
1 parent 6f6ad7f commit 17d6829

4 files changed

Lines changed: 147 additions & 0 deletions

File tree

‎cspell.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
"Junya",
209209
"jwalton",
210210
"kaios",
211+
"katex",
211212
"Kees",
212213
"khtml",
213214
"kibibytes",
@@ -270,6 +271,7 @@
270271
"moji",
271272
"MONEI",
272273
"mpath",
274+
"mrow",
273275
"mult",
274276
"multiplicator",
275277
"mycompany",

‎tooling/compare-css-tools.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const PACKAGES = [
6161
"animate.css@4",
6262
"beercss@5",
6363
"bootstrap@5",
64+
"bootstrap-icons@1",
6465
"bulma@1",
6566
"clean-css@5",
6667
@@ -73,21 +74,26 @@ const PACKAGES = [
7374
"@fortawesome/fontawesome-free@6",
7475
"fomantic-ui-css@2",
7576
"foundation-sites@6",
77+
7678
"lightningcss@1",
7779
"materialize-css@1",
7880
"milligram@1",
81+
"nes.css@2",
7982
"normalize.css@8",
83+
"open-props@1",
8084
"@patternfly/patternfly@6",
8185
"@picocss/pico@2",
8286
"postcss@8",
8387
"postcss-selector-parser@7",
8488
"prettier@3",
8589
"@primer/css@21",
8690
"purecss@3",
91+
"@radix-ui/themes@3",
8792
"sanitize.css@13",
8893
"@shoelace-style/shoelace@2",
8994
9095
"stylis@4",
96+
"swiper@14",
9197
9298
"semantic-ui-css@2",
9399
"@tabler/core@1",
@@ -96,6 +102,7 @@ const PACKAGES = [
96102
"@tdewolff/minify@2",
97103
"@tailwindcss/cli@4",
98104
"uikit@3",
105+
"video.js@8",
99106
"water.css@2"
100107
];
101108

@@ -151,31 +158,41 @@ const setup = async () => {
151158

152159
// Every installed stylesheet the comparison runs on: component frameworks, the
153160
// classless ones, and icon/animation/reset sheets that look nothing like them.
161+
162+
// The odd shapes earn their place: an icon font is thousands of one-declaration
163+
// rules, and Open Props is custom properties and almost nothing else.
154164
/** @type {[string, string][]} */
155165
const INSTALLED_FIXTURES = [
156166
["98.css", "98.css/dist/98.css"],
157167
["Animate.css 4", "animate.css/animate.css"],
158168
["Beer CSS 5", "beercss/dist/cdn/beer.css"],
159169
["Bootstrap 5 (full)", "bootstrap/dist/css/bootstrap.css"],
160170
["Bootstrap 5 (grid)", "bootstrap/dist/css/bootstrap-grid.css"],
171+
["Bootstrap Icons 1", "bootstrap-icons/font/bootstrap-icons.css"],
161172
["Bulma 1", "bulma/css/bulma.css"],
162173
["Fomantic-UI 2", "fomantic-ui-css/semantic.css"],
163174
["Font Awesome 6", "@fortawesome/fontawesome-free/css/all.css"],
164175
["Foundation 6", "foundation-sites/dist/css/foundation.css"],
176+
["KaTeX 0.18", "katex/dist/katex.css"],
165177
["Materialize 1", "materialize-css/dist/css/materialize.css"],
166178
["Milligram 1", "milligram/dist/milligram.css"],
179+
["NES.css 2", "nes.css/css/nes.css"],
167180
["normalize.css 8", "normalize.css/normalize.css"],
181+
["Open Props 1 (minified)", "open-props/open-props.min.css"],
168182
["PatternFly 6", "@patternfly/patternfly/patternfly-base.css"],
169183
["Pico 2", "@picocss/pico/css/pico.css"],
170184
["Primer 21", "@primer/css/dist/primer.css"],
171185
["Pure 3", "purecss/build/pure.css"],
186+
["Radix Themes 3 (components)", "@radix-ui/themes/components.css"],
172187
["sanitize.css 13", "sanitize.css/sanitize.css"],
173188
["Semantic UI 2", "semantic-ui-css/semantic.css"],
174189
["Shoelace 2 (light)", "@shoelace-style/shoelace/dist/themes/light.css"],
175190
["Spectre 0.5", "spectre.css/dist/spectre.css"],
191+
["Swiper 14", "swiper/swiper-bundle.css"],
176192
["Tabler 1", "@tabler/core/dist/css/tabler.css"],
177193
["Tachyons 4", "tachyons/css/tachyons.css"],
178194
["UIkit 3", "uikit/dist/css/uikit.css"],
195+
["Video.js 8", "video.js/dist/video-js.css"],
179196
["Water.css 2", "water.css/out/water.css"]
180197
];
181198

‎tooling/compare-html-tools.js‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const PACKAGES = [
5151
"angular-html-parser@9",
5252
"bootstrap@5",
5353
"dom-serializer@2",
54+
"@fortawesome/fontawesome-free@6",
5455
"htmlparser2@10",
5556
"js-beautify@1",
5657
"@minify-html/[email protected]",
@@ -231,6 +232,100 @@ ${css}
231232
</body>
232233
</html>`;
233234

235+
/**
236+
* A page of nothing but tables: rows a parser has to put in an implied
237+
* `<tbody>`, cells that span, and a `<caption>` and `<colgroup>` before them.
238+
* @param {number} rows how many rows to write
239+
* @returns {string} the page
240+
*/
241+
const tablePage = (rows) => {
242+
let body = "";
243+
for (let i = 0; i < rows; i++) {
244+
body += `\t\t<tr><th scope="row">Row ${i}</th><td>${i}</td><td colspan="2">${
245+
i * 2
246+
}</td><td><a href="/row/${i}">open</a></td></tr>\n`;
247+
}
248+
return `<!DOCTYPE html>
249+
<html lang="en">
250+
<head><meta charset="utf-8"><title>Report</title></head>
251+
<body>
252+
<table>
253+
\t<caption>Rows</caption>
254+
\t<colgroup><col><col span="2" class="numeric"><col></colgroup>
255+
\t<thead><tr><th scope="col">Name</th><th scope="col">A</th><th scope="col">B</th><th scope="col">Link</th></tr></thead>
256+
${body}\t<tfoot><tr><td colspan="4">${rows} rows</td></tr></tfoot>
257+
</table>
258+
</body>
259+
</html>`;
260+
};
261+
262+
// Every shape §13.2 has a recovery rule for: implied end tags, formatting
263+
// elements reopened across a block, and text a table fosters out of itself.
264+
const TAG_SOUP = `<!DOCTYPE html>
265+
<html>
266+
<head><title>Soup</title>
267+
<body>
268+
<p>One
269+
<p>Two<b>bold<i>both</b>italic</i>
270+
<ul>
271+
<li>first
272+
<li>second<div>block inside a list item
273+
<li>third
274+
</ul>
275+
<table>fostered text<tr><td>cell<td>next
276+
<tr><th>head
277+
</table>
278+
<div><span>unclosed
279+
</div>
280+
</p></span>
281+
<form><form><input name=a><button>go
282+
<select><option>a<option>b</select>
283+
<a href="/x"><a href="/y">nested anchors</a>
284+
<font size=3><p>font across a paragraph</font>
285+
</body>`;
286+
287+
// A page as a component library ships it: templates that are not rendered,
288+
// a declarative shadow root, and elements the parser knows nothing about.
289+
const WEB_COMPONENTS = `<!DOCTYPE html>
290+
<html lang="en">
291+
<head><meta charset="utf-8"><title>Elements</title></head>
292+
<body>
293+
<my-app theme="dark">
294+
\t<template shadowrootmode="open">
295+
\t\t<style>:host{display:block}::slotted(p){margin:0}</style>
296+
\t\t<slot name="header"></slot>
297+
\t\t<slot></slot>
298+
\t</template>
299+
\t<h1 slot="header">Title</h1>
300+
\t<p>Light DOM child</p>
301+
</my-app>
302+
<template id="row">
303+
\t<tr><td><slot name="cell"></slot></td></tr>
304+
</template>
305+
<ul is="sortable-list" data-sort="asc">
306+
\t<li><x-item value="1">One</x-item></li>
307+
\t<li><x-item value="2">Two</x-item></li>
308+
</ul>
309+
<script type="module">customElements.define("x-item", class extends HTMLElement {});</script>
310+
</body>
311+
</html>`;
312+
313+
/**
314+
* @param {string} sprite an SVG document
315+
* @returns {string} it inlined into a page, as an icon sprite is used
316+
*/
317+
const spritePage = (sprite) => `<!DOCTYPE html>
318+
<html lang="en">
319+
<head><meta charset="utf-8"><title>Icons</title></head>
320+
<body>
321+
<div hidden>
322+
${sprite}
323+
</div>
324+
<p><svg width="16" height="16" aria-hidden="true"><use href="#user"></use></svg> Inline reference</p>
325+
<math><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow></math>
326+
</body>
327+
</html>`;
328+
234329
/**
235330
* Two kinds of real HTML: an app shell (attribute- and `<meta>`-heavy, little
236331
* text) and a document (mostly text, with the `<pre>` blocks whose whitespace no
@@ -270,10 +365,23 @@ const fixtures = async () => {
270365
}
271366
for (const [label, file] of [
272367
["webpack README (rendered)", path.join(ROOT, "README.md")],
368+
["webpack AGENTS (rendered)", path.join(ROOT, "AGENTS.md")],
273369
["webpack CHANGELOG (rendered)", path.join(ROOT, "CHANGELOG.md")]
274370
]) {
275371
out.push([label, marked.parse(await fs.promises.readFile(file, "utf8"))]);
276372
}
373+
out.push(["Table report (600 rows)", tablePage(600)]);
374+
out.push(["Tag soup", TAG_SOUP]);
375+
out.push(["Web components", WEB_COMPONENTS]);
376+
out.push([
377+
"Icon sprite (inlined SVG)",
378+
spritePage(
379+
await fs.promises.readFile(
380+
path.join(MODULES, "@fortawesome/fontawesome-free/sprites/solid.svg"),
381+
"utf8"
382+
)
383+
)
384+
]);
277385
return out;
278386
};
279387
// Each entry builds its callable on demand, so the measuring worker loads only

‎tooling/compare-js-tools.js‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const PACKAGES = [
7171
"chart.js@4",
7272
"core-js-bundle@3",
7373
"d3@7",
74+
"echarts@6",
7475
"escodegen@2",
7576
7677
"espree@11",
@@ -79,13 +80,17 @@ const PACKAGES = [
7980
"jquery@3",
8081
"lodash@4",
8182
"meriyah@7",
83+
"immutable@5",
8284
"moment@2",
8385
8486
87+
"pdfjs-dist@6",
88+
"preact@10",
8589
"prettier@3",
8690
"react-dom@18",
8791
"react@18",
8892
"rxjs@7",
93+
"swagger-ui-dist@5",
8994
"terser@5",
9095
9196
"typescript@5",
@@ -95,20 +100,35 @@ const PACKAGES = [
95100

96101
// Bundles as they ship: the ES5 ones every site still loads, the modern ones
97102
// written in classes and modules, and two that dwarf both.
103+
104+
// The minified rows matter on their own: that is the shape most of what a build
105+
// reads from `node_modules` is in, and it is where a parser's hot loop lives.
98106
/** @type {[string, string, "module" | "script"][]} */
99107
const INSTALLED_FIXTURES = [
108+
["Preact 10 (ESM)", "preact/dist/preact.module.js", "module"],
100109
["jQuery 3", "jquery/dist/jquery.js", "script"],
110+
["jQuery 3 (minified)", "jquery/dist/jquery.min.js", "script"],
101111
["Moment 2", "moment/moment.js", "script"],
102112
["axios 1", "axios/dist/axios.js", "script"],
103113
["Lodash 4", "lodash/lodash.js", "script"],
104114
["Bootstrap 5", "bootstrap/dist/js/bootstrap.bundle.js", "script"],
105115
["Chart.js 4", "chart.js/dist/chart.umd.js", "script"],
106116
["D3 7", "d3/dist/d3.js", "script"],
107117
["RxJS 7", "rxjs/dist/bundles/rxjs.umd.js", "script"],
118+
["Immutable 5 (ESM)", "immutable/dist/immutable.es.js", "module"],
108119
["React DOM 18 (dev)", "react-dom/umd/react-dom.development.js", "script"],
120+
[
121+
"React DOM 18 (production)",
122+
"react-dom/umd/react-dom.production.min.js",
123+
"script"
124+
],
109125
["core-js 3 (bundle)", "core-js-bundle/index.js", "script"],
110126
["Vue 3 (ESM)", "vue/dist/vue.esm-browser.js", "module"],
127+
["Vue 3 (production)", "vue/dist/vue.runtime.global.prod.js", "script"],
111128
["three (ESM)", "three/build/three.module.js", "module"],
129+
["pdf.js 6 (ESM)", "pdfjs-dist/build/pdf.mjs", "module"],
130+
["Swagger UI 5 (bundle)", "swagger-ui-dist/swagger-ui-bundle.js", "script"],
131+
["ECharts 6", "echarts/dist/echarts.js", "script"],
112132
["Babel 7 (standalone)", "@babel/standalone/babel.js", "script"],
113133
["TypeScript 5", "typescript/lib/typescript.js", "script"]
114134
];

0 commit comments

Comments
 (0)