icon() (src/web/icons.ts:98) inlines the whole drawing every time it is called — right when a page uses three icons, wasteful when a list of thirty rows uses a hundred. The browser has had the answer since SVG 1.1: define each shape once as a <symbol> and reference it with <use>. Same markup pipeline, same zero dependencies, same file — about twenty kilobytes off the first page a person sees, and more off the longer lists.
Acceptance
Files I expect to change
src/web/icons.ts (the symbol and the reference), src/web/layout.ts (emit the block for what the page used), test/web.test.ts.
Risks
Collecting what a page used means the layout must know before it renders the head — or the block goes at the end of <body>, which is legal and referenced fine by <use> earlier in the document. Pick one and say which; do not thread a collector through every component.
<use> and accessibility. The shadow content of a <use> is not focusable, but the wrapping <svg> still needs its aria-hidden; any control that is icon-only still needs its own aria-label, exactly as the module's doc comment already says.
Diminishing returns. After #114 takes the 27 KB script out, this is the largest remaining chunk of the front door. It is also the last easy one — say in the pull what the page weighs when you are done.
A fifth of the studio's front door is the same twenty drawings, sent over and over.
Measured on the deployed forge, signed in, at
/:icon()(src/web/icons.ts:98) inlines the whole drawing every time it is called — right when a page uses three icons, wasteful when a list of thirty rows uses a hundred. The browser has had the answer since SVG 1.1: define each shape once as a<symbol>and reference it with<use>. Same markup pipeline, same zero dependencies, same file — about twenty kilobytes off the first page a person sees, and more off the longer lists.Acceptance
Files I expect to change
src/web/icons.ts(the symbol and the reference),src/web/layout.ts(emit the block for what the page used),test/web.test.ts.Risks
<body>, which is legal and referenced fine by<use>earlier in the document. Pick one and say which; do not thread a collector through every component.<use>and accessibility. The shadow content of a<use>is not focusable, but the wrapping<svg>still needs itsaria-hidden; any control that is icon-only still needs its ownaria-label, exactly as the module's doc comment already says.Suggested: Torque.