Skip to content

Replace embedded PNG in research-tool icon with native SVG to reduce file size - #1488

Open
brentswisher wants to merge 3 commits into
developfrom
fix/research-tool-icon-filesize
Open

brentswisher wants to merge 3 commits into
developfrom
fix/research-tool-icon-filesize

Conversation

@brentswisher

@brentswisher brentswisher commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

This change: (check at least one)

  • Adds a new feature
  • Fixes a bug
  • Improves maintainability
  • Improves documentation
  • Is a release activity

Is this a breaking change? (check one)

  • Yes
  • No

Is the: (complete all)

  • Title of this pull request clear, concise, and indicative of the issue number it addresses, if any?
  • Test suite(s) passing?
  • Code coverage maximal?
  • Changeset added?

What does this change address?
Closes #1136. The research-tool icon is currently a PNG embedded as base64 inside an SVG wrapper, making it 1.1MB, the largest chunk in consuming MFE bundles.

How does this change work?

  • Redraws the icon as native SVG (~12KB, no embedded image), visually matching the original.
  • Ten gradient layers (radial and linear) were fit numerically against the original's pixels, minimizing perceptual (CIELAB) color difference.
  • The sphere's outline is a 512-point path traced from the original's actual opaque region (it is not a perfect circle), so edge anti-aliasing matches.
  • The layers are drawn as plain rectangles inside <g style="isolation: isolate"> and cut out once by a single alpha mask.

Additional context
(This doesn't really matter, but was interesting to me)
The SVG was generated using Claude. The Figma source for this icon is the same 1920×1920 bitmap, so there was no vector original to export. Claude redrew it by numerically fitting ten SVG gradient layers to the original's pixels, and traced the sphere's actual outline (it isn't a perfect circle) as a 512-point path.

The new icon was compared pixel by pixel against the original in Chromium, Firefox and WebKit (via Playwright) and then iterated on until it matched closely enough. The comparison covered 24, 48 and 96px, 1×–3× pixel density, and white, dark and colored backgrounds. Each icon was rendered the way pharos-icon renders it: injected into a 24×24 inside a shadow root.

Differences on iterations were measured with ΔE (CIEDE2000), the standard measure of how different two colors look to a person. Below 1 is invisible, around 2 is where a careful observer starts to notice, and black vs. white is 100.

Inside the sphere, the average difference is ΔE ≤ 0.74 and 99% of pixels are at ΔE ≤ 2.2. On the anti-aliased edge, differences from the original are about as large as the differences between the original PNG rendered in two browsers. Compared against an exact downscale of the source artwork, the new edge is as close as the browsers' own PNG renderings, or closer.

The chromatic builds highlight where it deviates slightly from being a perfect 1:1 match (the green highlighted points):

Screenshot 2026-11-04 at 4 52 27 PM

@brentswisher
brentswisher requested a review from a team as a code owner November 4, 2026 21:49
@brentswisher
brentswisher requested review from daneah, jialin-he and satya-achanta-venkata and removed request for a team November 4, 2026 21:49
@brentswisher brentswisher self-assigned this Nov 4, 2026
@changeset-bot

changeset-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5e441f2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ithaka/pharos Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brentswisher brentswisher changed the title fix(icon): replace embedded PNG in research-tool icon with native SVG (#1136) Replace embedded PNG in research-tool icon with native SVG to reduce file size Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
packages/pharos/lib/index.js 56.4 KB (0%)

@brentswisher
brentswisher force-pushed the fix/research-tool-icon-filesize branch from 055e246 to 5e441f2 Compare November 4, 2026 21:54
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.

Icon: File size of research-tool icon is larger than expected

1 participant