Skip to content

Commit 381189d

Browse files
committed
chore: add readme link to size and bot
1 parent 1d9a552 commit 381189d

File tree

4 files changed

+133
-84
lines changed

4 files changed

+133
-84
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Update size
2+
3+
on:
4+
push:
5+
branches: main
6+
workflow_dispatch:
7+
# allows triggering from the github UI
8+
jobs:
9+
check-for-doc-changes:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v3
15+
with:
16+
node-version: 20
17+
cache: npm
18+
- uses: google/wireit@setup-github-actions-caching/v1
19+
20+
- name: Install Dependencies
21+
run: npm ci
22+
23+
- name: Update Size
24+
run: npm run update-size
25+
26+
- name: Check if update-size produces git diff
27+
id: ifChange
28+
run: git diff --exit-code || echo "::set-output name=changed::yes"
29+
30+
- name: Create or update PR
31+
if: steps.ifChange.outputs.changed == 'yes'
32+
uses: peter-evans/create-pull-request@v5
33+
with:
34+
token: ${{ secrets.LIT_ROBOT_ACCESS_TOKEN }}
35+
commit-message: 'chore: update sizes'
36+
author: lit-robot <lit-robot@google.com>
37+
committer: lit-robot <lit-robot@google.com>
38+
title: 'chore: update sizes'
39+
body: This PR was auto generated by the update-size-on-main GitHub action.
40+
reviewers: e111077,asyncliz
41+
branch: auto-update-size
42+
# Don't automatically add Ready for Google label until we're ready
43+
# since this will be noisy.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ Google's open-source design system.
1616
- [Introduction](docs/intro.md)
1717
- [Roadmap](docs/roadmap.md)
1818
- [Quick start](docs/quick-start.md)
19+
- [Bundle sizes](docs/size.md)
1920
- [Component docs](docs/components/)
2021
- [Browser support and FAQ](docs/support.md)

docs/size.md

Lines changed: 70 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,83 +4,92 @@
44

55
<!--*
66
# Document freshness: For more information, see go/fresh-source.
7-
freshness: { owner: 'lizmitchell' reviewed: '2023-12-11' }
7+
freshness: { owner: 'lizmitchell' reviewed: '2023-12-13' }
88
*-->
99

1010
<!-- [TOC] -->
1111

1212
This doc tracks important size metrics for Material Web Components.
1313

14+
Sizes are tracked in bundles. A bundle is a single `.js` file for one or more
15+
components that includes all of the JavaScript and CSS needed, minus external
16+
dependencies. We track three metrics:
17+
1418
- **gzip** - minified and compressed. This impacts download size, which can
15-
take longer on slow networks.
19+
take longer over slow networks.
1620

1721
- **minified** - minified and unpacked. This impacts the time it takes a page
1822
to be interactive, which can take longer on some devices.
1923

24+
- **% CSS** - the amount of CSS compared to JavaScript. The bundle includes
25+
both JS and CSS, so this helps track changes to JS logic and CSS styles
26+
separately.
27+
28+
<!-- Autogenerated below, do not update! -->
2029
<!-- MWC_UPDATE_TRACKING_START -->
2130

22-
<small>Last updated 2023-12-12.</small>
31+
<sub>Last updated 2023-12-13.</sub>
2332

2433
<!-- mdformat off(autogenerated might break rendering in catalog) -->
2534

26-
Component | gzip | minified | Import
27-
--- | --- | --- | ---
28-
**All** | **70.0kb** | 451.6kb <small>*(66% CSS)*</small> | *@material/web/all.js*
29-
**Common** | **51.4kb** | 281.9kb <small>*(54% CSS)*</small> | *@material/web/common.js*
30-
**Button** | **8.0kb** | 46.3kb <small>*(66% CSS)*</small> |
31-
| 6.7kb | 27.4kb <small>*(49% CSS)*</small> | *@material/web/button/elevated-button.js*
32-
| 6.6kb | 27.3kb <small>*(49% CSS)*</small> | *@material/web/button/filled-button.js*
33-
| 6.7kb | 27.7kb <small>*(49% CSS)*</small> | *@material/web/button/filled-tonal-button.js*
34-
| 6.4kb | 25.7kb <small>*(48% CSS)*</small> | *@material/web/button/outlined-button.js*
35-
| 6.2kb | 24.2kb <small>*(45% CSS)*</small> | *@material/web/button/text-button.js*
36-
**Checkbox** | **7.0kb** | 28.5kb <small>*(43% CSS)*</small> | *@material/web/checkbox/checkbox.js*
37-
**Chips** | **9.9kb** | 60.1kb <small>*(64% CSS)*</small> |
38-
| 4.8kb | 16.4kb <small>*(22% CSS)*</small> | *@material/web/chips/chip-set.js*
39-
| 6.3kb | 26.8kb <small>*(51% CSS)*</small> | *@material/web/chips/assist-chip.js*
40-
| 7.8kb | 36.7kb <small>*(56% CSS)*</small> | *@material/web/chips/filter-chip.js*
41-
| 7.3kb | 33.6kb <small>*(54% CSS)*</small> | *@material/web/chips/input-chip.js*
42-
| 6.4kb | 27.2kb <small>*(51% CSS)*</small> | *@material/web/chips/suggestion-chip.js*
43-
**Dialog** | **4.2kb** | 15.2kb <small>*(36% CSS)*</small> | *@material/web/dialog/dialog.js*
44-
**Divider** | **0.7kb** | 1.4kb <small>*(39% CSS)*</small> | *@material/web/divider/divider.js*
45-
**Elevation** | **0.7kb** | 1.7kb <small>*(62% CSS)*</small> | *@material/web/elevation/elevation.js*
46-
**Fab** | **6.9kb** | 37.1kb <small>*(67% CSS)*</small> |
47-
| 6.6kb | 32.8kb <small>*(64% CSS)*</small> | *@material/web/fab/fab.js*
48-
| 5.8kb | 24.6kb <small>*(51% CSS)*</small> | *@material/web/fab/branded-fab.js*
49-
**Field** | **6.0kb** | 40.5kb <small>*(83% CSS)*</small> |
50-
| 4.6kb | 24.8kb <small>*(75% CSS)*</small> | *@material/web/field/filled-field.js*
51-
| 5.0kb | 27.1kb <small>*(76% CSS)*</small> | *@material/web/field/outlined-field.js*
52-
**Focus** | **1.6kb** | 5.2kb <small>*(46% CSS)*</small> | *@material/web/focus/md-focus-ring.js*
53-
**Icon** | **0.7kb** | 1.3kb <small>*(46% CSS)*</small> | *@material/web/icon/icon.js*
54-
**Icon button** | **7.3kb** | 42.0kb <small>*(65% CSS)*</small> |
55-
| 5.8kb | 23.1kb <small>*(42% CSS)*</small> | *@material/web/iconbutton/icon-button.js*
56-
| 6.0kb | 25.0kb <small>*(45% CSS)*</small> | *@material/web/iconbutton/filled-icon-button.js*
57-
| 6.0kb | 25.5kb <small>*(46% CSS)*</small> | *@material/web/iconbutton/filled-tonal-icon-button.js*
58-
| 6.0kb | 24.6kb <small>*(45% CSS)*</small> | *@material/web/iconbutton/outlined-icon-button.js*
59-
**List** | **6.9kb** | 27.2kb <small>*(35% CSS)*</small> |
60-
| 1.6kb | 4.5kb <small>*(5% CSS)*</small> | *@material/web/list/list.js*
61-
| 5.8kb | 23.0kb <small>*(40% CSS)*</small> | *@material/web/list/list-item.js*
62-
**Menu** | **13.5kb** | 53.9kb <small>*(23% CSS)*</small> |
63-
| 7.9kb | 28.8kb <small>*(17% CSS)*</small> | *@material/web/menu/menu.js*
64-
| 6.5kb | 25.6kb <small>*(37% CSS)*</small> | *@material/web/menu/menu-item.js*
65-
| 8.4kb | 31.9kb <small>*(11% CSS)*</small> | *@material/web/menu/sub-menu.js*
66-
**Progress** | **3.5kb** | 13.9kb <small>*(70% CSS)*</small> |
67-
| 2.6kb | 8.6kb <small>*(64% CSS)*</small> | *@material/web/progress/linear-progress.js*
68-
| 2.2kb | 7.4kb <small>*(57% CSS)*</small> | *@material/web/progress/circular-progress.js*
69-
**Radio** | **6.9kb** | 26.0kb <small>*(31% CSS)*</small> | *@material/web/radio/radio.js*
70-
**Ripple** | **2.8kb** | 7.9kb <small>*(14% CSS)*</small> | *@material/web/ripple/ripple.js*
71-
**Select** | **25.6kb** | 142.5kb <small>*(57% CSS)*</small> |
72-
| 17.8kb | 89.3kb <small>*(48% CSS)*</small> | *@material/web/select/filled-select.js*
73-
| 18.1kb | 89.9kb <small>*(48% CSS)*</small> | *@material/web/select/outlined-select.js*
74-
| 6.6kb | 26.6kb <small>*(36% CSS)*</small> | *@material/web/select/select-option.js*
75-
**Slider** | **9.7kb** | 45.0kb <small>*(49% CSS)*</small> | *@material/web/slider/slider.js*
76-
**Switch** | **7.8kb** | 34.8kb <small>*(53% CSS)*</small> | *@material/web/switch/switch.js*
77-
**Tabs** | **7.9kb** | 35.1kb <small>*(50% CSS)*</small> |
78-
| 6.2kb | 21.9kb <small>*(25% CSS)*</small> | *@material/web/tabs/tabs.js*
79-
| 6.3kb | 25.6kb <small>*(48% CSS)*</small> | *@material/web/tabs/primary-tab.js*
80-
| 6.2kb | 25.2kb <small>*(48% CSS)*</small> | *@material/web/tabs/secondary-tab.js*
81-
**Text field** | **13.7kb** | 93.0kb <small>*(74% CSS)*</small> |
82-
| 10.7kb | 60.8kb <small>*(62% CSS)*</small> | *@material/web/textfield/filled-text-field.js*
83-
| 10.9kb | 61.3kb <small>*(62% CSS)*</small> | *@material/web/textfield/outlined-text-field.js*
35+
Component | gzip | minified | *% CSS* | Import
36+
--- | --- | --- | --- | ---
37+
**All** | **70.0kb** | 451.6kb | *66% CSS* | `@material/web/all.js`
38+
**Common** | **51.4kb** | 281.9kb | *54% CSS* | `@material/web/common.js`
39+
**Button** | **8.0kb** | 46.3kb | *66% CSS* |
40+
| 6.7kb | 27.4kb | *49% CSS* | `@material/web/button/elevated-button.js`
41+
| 6.6kb | 27.3kb | *49% CSS* | `@material/web/button/filled-button.js`
42+
| 6.7kb | 27.7kb | *49% CSS* | `@material/web/button/filled-tonal-button.js`
43+
| 6.4kb | 25.7kb | *48% CSS* | `@material/web/button/outlined-button.js`
44+
| 6.2kb | 24.2kb | *45% CSS* | `@material/web/button/text-button.js`
45+
**Checkbox** | **7.0kb** | 28.5kb | *43% CSS* | `@material/web/checkbox/checkbox.js`
46+
**Chips** | **9.9kb** | 60.1kb | *64% CSS* |
47+
| 4.8kb | 16.4kb | *22% CSS* | `@material/web/chips/chip-set.js`
48+
| 6.3kb | 26.8kb | *51% CSS* | `@material/web/chips/assist-chip.js`
49+
| 7.8kb | 36.7kb | *56% CSS* | `@material/web/chips/filter-chip.js`
50+
| 7.3kb | 33.6kb | *54% CSS* | `@material/web/chips/input-chip.js`
51+
| 6.4kb | 27.2kb | *51% CSS* | `@material/web/chips/suggestion-chip.js`
52+
**Dialog** | **4.2kb** | 15.2kb | *36% CSS* | `@material/web/dialog/dialog.js`
53+
**Divider** | **0.7kb** | 1.4kb | *39% CSS* | `@material/web/divider/divider.js`
54+
**Elevation** | **0.7kb** | 1.7kb | *62% CSS* | `@material/web/elevation/elevation.js`
55+
**Fab** | **6.9kb** | 37.1kb | *67% CSS* |
56+
| 6.6kb | 32.8kb | *64% CSS* | `@material/web/fab/fab.js`
57+
| 5.8kb | 24.6kb | *51% CSS* | `@material/web/fab/branded-fab.js`
58+
**Field** | **6.0kb** | 40.5kb | *83% CSS* |
59+
| 4.6kb | 24.8kb | *75% CSS* | `@material/web/field/filled-field.js`
60+
| 5.0kb | 27.1kb | *76% CSS* | `@material/web/field/outlined-field.js`
61+
**Focus** | **1.6kb** | 5.2kb | *46% CSS* | `@material/web/focus/md-focus-ring.js`
62+
**Icon** | **0.7kb** | 1.3kb | *46% CSS* | `@material/web/icon/icon.js`
63+
**Icon button** | **7.3kb** | 42.0kb | *65% CSS* |
64+
| 5.8kb | 23.1kb | *42% CSS* | `@material/web/iconbutton/icon-button.js`
65+
| 6.0kb | 25.0kb | *45% CSS* | `@material/web/iconbutton/filled-icon-button.js`
66+
| 6.0kb | 25.5kb | *46% CSS* | `@material/web/iconbutton/filled-tonal-icon-button.js`
67+
| 6.0kb | 24.6kb | *45% CSS* | `@material/web/iconbutton/outlined-icon-button.js`
68+
**List** | **6.9kb** | 27.2kb | *35% CSS* |
69+
| 1.6kb | 4.5kb | *5% CSS* | `@material/web/list/list.js`
70+
| 5.8kb | 23.0kb | *40% CSS* | `@material/web/list/list-item.js`
71+
**Menu** | **13.5kb** | 53.9kb | *23% CSS* |
72+
| 7.9kb | 28.8kb | *17% CSS* | `@material/web/menu/menu.js`
73+
| 6.5kb | 25.6kb | *37% CSS* | `@material/web/menu/menu-item.js`
74+
| 8.4kb | 31.9kb | *11% CSS* | `@material/web/menu/sub-menu.js`
75+
**Progress** | **3.5kb** | 13.9kb | *70% CSS* |
76+
| 2.6kb | 8.6kb | *64% CSS* | `@material/web/progress/linear-progress.js`
77+
| 2.2kb | 7.4kb | *57% CSS* | `@material/web/progress/circular-progress.js`
78+
**Radio** | **6.9kb** | 26.0kb | *31% CSS* | `@material/web/radio/radio.js`
79+
**Ripple** | **2.8kb** | 7.9kb | *14% CSS* | `@material/web/ripple/ripple.js`
80+
**Select** | **25.6kb** | 142.5kb | *57% CSS* |
81+
| 17.8kb | 89.3kb | *48% CSS* | `@material/web/select/filled-select.js`
82+
| 18.1kb | 89.9kb | *48% CSS* | `@material/web/select/outlined-select.js`
83+
| 6.6kb | 26.6kb | *36% CSS* | `@material/web/select/select-option.js`
84+
**Slider** | **9.7kb** | 45.0kb | *49% CSS* | `@material/web/slider/slider.js`
85+
**Switch** | **7.8kb** | 34.8kb | *53% CSS* | `@material/web/switch/switch.js`
86+
**Tabs** | **7.9kb** | 35.1kb | *50% CSS* |
87+
| 6.2kb | 21.9kb | *25% CSS* | `@material/web/tabs/tabs.js`
88+
| 6.3kb | 25.6kb | *48% CSS* | `@material/web/tabs/primary-tab.js`
89+
| 6.2kb | 25.2kb | *48% CSS* | `@material/web/tabs/secondary-tab.js`
90+
**Text field** | **13.7kb** | 93.0kb | *74% CSS* |
91+
| 10.7kb | 60.8kb | *62% CSS* | `@material/web/textfield/filled-text-field.js`
92+
| 10.9kb | 61.3kb | *62% CSS* | `@material/web/textfield/outlined-text-field.js`
8493

8594
<!-- mdformat on(autogenerated might break rendering in catalog) -->
8695

scripts/size/update-size.ts

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
import * as fs from 'fs/promises';
88

9-
import {MarkdownTable} from '../analyzer/markdown-tree-builder.js';
10-
import {COMPONENT_CUSTOM_ELEMENTS} from '../component-custom-elements.js';
11-
import {Bundle, Size, getBundleSize} from './bundle-size.js';
9+
import { MarkdownTable } from '../analyzer/markdown-tree-builder.js';
10+
import { COMPONENT_CUSTOM_ELEMENTS } from '../component-custom-elements.js';
11+
import { Bundle, Size, getBundleSize } from './bundle-size.js';
1212

1313
// The bundles to track sizes for.
1414

@@ -28,7 +28,7 @@ const bundles: Bundle[] = [
2828
).map((component) => {
2929
const tsCustomElementPaths = COMPONENT_CUSTOM_ELEMENTS[component];
3030
const jsCustomElementPaths = tsCustomElementPaths.map((tsPath) =>
31-
tsPath.replace(/\.ts$/, '.js'),
31+
tsPath.replace(/\.ts$/, '.js')
3232
);
3333

3434
return {
@@ -41,31 +41,33 @@ const bundles: Bundle[] = [
4141
// Compute bundle sizes.
4242

4343
const bundleSizes = await Promise.all(
44-
bundles.map((bundle) => getBundleSize(bundle)),
44+
bundles.map((bundle) => getBundleSize(bundle))
4545
);
4646

4747
// Create a markdown table with size data.
4848

49-
const columns = ['Component', 'gzip', 'minified', 'Import'];
49+
const columns = ['Component', 'gzip', 'minified', '*% CSS*', 'Import'];
5050
const rows: string[][] = [];
51-
for (const {name, size, inputs} of bundleSizes) {
51+
for (const { name, size, inputs } of bundleSizes) {
5252
rows.push([
5353
`**${camelToSentenceCase(name)}**`,
5454
`**${bytesToString(size.gzip)}**`,
55-
getJsAndCss(size),
56-
inputs.length === 1 ? `*${getImport(inputs[0].input)}*` : '',
55+
bytesToString(size.raw),
56+
getCssPercent(size),
57+
inputs.length === 1 ? getImport(inputs[0].input) : '',
5758
]);
5859

5960
if (inputs.length > 1) {
6061
rows.push(
6162
...inputs.map((input) => {
6263
return [
6364
'',
64-
`${bytesToString(input.size.gzip)}`,
65-
`${getJsAndCss(input.size)}`,
66-
`*${getImport(input.input)}*`,
65+
bytesToString(input.size.gzip),
66+
bytesToString(input.size.raw),
67+
getCssPercent(input.size),
68+
getImport(input.input),
6769
];
68-
}),
70+
})
6971
);
7072
}
7173
}
@@ -77,7 +79,7 @@ for (const row of rows) {
7779

7880
// Update markdown file.
7981

80-
const markdownContent = await fs.readFile('docs/size.md', {encoding: 'utf8'});
82+
const markdownContent = await fs.readFile('docs/size.md', { encoding: 'utf8' });
8183
const updateTrackingStart = '<!-- MWC_UPDATE_TRACKING_START -->';
8284
const updateTrackingEnd = '<!-- MWC_UPDATE_TRACKING_END -->';
8385

@@ -88,7 +90,7 @@ const newMarkdownContent = [
8890
markdownContent.substring(0, markdownContent.indexOf(updateTrackingStart)),
8991
updateTrackingStart,
9092
'\n\n',
91-
`<small>Last updated ${nowString}.</small>\n\n`,
93+
`<sub>Last updated ${nowString}.</sub>\n\n`,
9294
markdownTable.toString(),
9395
'\n\n',
9496
markdownContent.substring(markdownContent.indexOf(updateTrackingEnd)),
@@ -99,23 +101,17 @@ await fs.writeFile('docs/size.md', newMarkdownContent);
99101
// Text formatting functions for markdown table.
100102

101103
function getImport(input: string) {
102-
return `@material/web/${input}`;
104+
return `\`@material/web/${input}\``;
103105
}
104106

105107
function getCssPercent(size: Size) {
106-
return `${Math.round((size.css / size.raw) * 100)}%`;
108+
return `*${Math.round((size.css / size.raw) * 100)}% CSS*`;
107109
}
108110

109111
function bytesToString(bytes: number) {
110112
return `${(Math.round(bytes / 100) / 10).toFixed(1)}kb`;
111113
}
112114

113-
function getJsAndCss(size: Size) {
114-
return `${bytesToString(size.raw)} <small>*(${getCssPercent(
115-
size,
116-
)} CSS)*</small>`;
117-
}
118-
119115
function camelToSentenceCase(value: string) {
120116
const withSpaces = value.replaceAll(/([a-z])([A-Z])/g, '$1 $2');
121117
return withSpaces[0].toUpperCase() + withSpaces.slice(1).toLowerCase();

0 commit comments

Comments
 (0)