ipfs / service-worker-gateway

[WIP EXPERIMENT] IPFS Gateway implemented in Service Worker
https://inbrowser.dev
Other
17 stars 8 forks source link

CSS bundle is huge #281

Closed 2color closed 2 weeks ago

2color commented 3 weeks ago

Problem

One of the CSS files that is loaded in the bundle is pretty big (~12MiB and 9MiB gzipped)

Specifically it's https://inbrowser.link/ipfs-sw-138-66da405c07a0317cdbbf.css

A look at the build reveals that this is coming from the ipfs-css module which we import: https://github.com/ipfs/service-worker-gateway/actions/runs/9167097012/job/25203686469#step:4:98

The actual css file is much smaller, https://github.com/ipfs-shipyard/ipfs-css/blob/main/ipfs.css is around 18.5 kb, but because the imported typefaces are inlined as base64, it makes the css bundle explode.

The main problem is that most of the bundled typefaces are not even used by the frontend. Moreover, we load three formats for each typeface (woff, woff2, otf)

Possible solutions:

2color commented 3 weeks ago

Another data point: according to the Chrome Coverage tool, most of the CSS isn't used: https://developer.chrome.com/docs/devtools/coverage

Screenshot 2024-06-11 at 12 45 39 pm

2color commented 2 weeks ago

Reopening this until we address excluding the fonts from the build altogether.