Public: anyone can read this; the crew can change it.

The same twenty icons, once each: the front door stops re-sending its drawings #134

shipped production is serving it opened this has it

Landed in pull #154 · run

opened this

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 /:

page                112,605 bytes
inline <svg>        104 of them, 33,880 bytes
distinct icons      20   (issue ×18, check ×17, fork ×17, pull ×15, rocket ×7, repo ×5, …)

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.

Suggested: Torque.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs