Skip to content

refactor: Inline SVG defs#1358

Open
rschristian wants to merge 1 commit into
masterfrom
refactor/inline-svg-defs
Open

refactor: Inline SVG defs#1358
rschristian wants to merge 1 commit into
masterfrom
refactor/inline-svg-defs

Conversation

@rschristian
Copy link
Copy Markdown
Member

@rschristian rschristian commented Nov 13, 2025

src/assets/icons.svg makes up the header icons & the "link" icon used on heading elements throughout our doc pages. Inlining it adds ~1.6kb to the HTML (9.49kb -> 11.09kb, in the preview env) but these are always going to be within the initial viewport of every page so it probably makes sense to do. Trading cachability for faster rendering.

There's no way to do preloading of SVG sprite sheets yet (https://issues.chromium.org/issues/40681653 & whatwg/fetch#1012 are long-standing issues) so this is the next best option.

@github-actions
Copy link
Copy Markdown

Size Change: -1 B (0%)

Total Size: 449 kB

ℹ️ View Unchanged
Filename Size Change
build/assets/blog-page-********.js 259 B +2 B (+0.78%)
build/assets/docsearch-********.js 28.9 kB +1 B (0%)
build/assets/errors-********.js 342 B 0 B
build/assets/index-********.js 32.5 kB -7 B (-0.02%)
build/assets/index-********.css 9.65 kB 0 B
build/assets/repl-********.css 1.51 kB 0 B
build/assets/repl-********.js 148 kB -1 B (0%)
build/assets/repl-page-********.js 7.66 kB +2 B (+0.03%)
build/assets/repl.worker-********.js 213 kB 0 B
build/assets/style-********.css 3.07 kB 0 B
build/assets/style.module-********.js 159 B 0 B
build/assets/tutorial-page-********.js 1.99 kB +2 B (+0.1%)
build/assets/tutorial-page-********.css 1.76 kB 0 B

compressed-size-action

Comment thread index.html
<link href="https://www.google-analytics.com" rel="preconnect" crossorigin="anonymous">
</head>
<body class="banner">
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively could keep this separate & just write a Vite plugin to inline it into the HTML, dunno if that's better or worse.

@rschristian rschristian marked this pull request as ready for review November 14, 2025 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant