-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library is 64Kb, minified #16
Comments
the package is not side-effect free as it registers a custom element (well, 2 of them actually, as there is an internal one) |
Whooping 64KB of minified code for a small Baseline Status widget is over the roof. It should fit in <20KB of minified code. |
I think a big part of it is the string containing CSS code. A JS minifier won't be able to reduce the size of that string, which takes half of the size of the file. |
I agree this is a big problem that we need to solve. We shouldn't be imposing this performance cost to the hosting webpages. Looking at the code, the SVG browser icons seem to be responsible for a large portion of the total size of the source file. I'm estimating around 60% of it. |
Regarding the SVG, we need to think about simplifying them substantially. The size at which they get rendered by default is very small and doesn't warrant that much details which most users will not see. If I save the SVG string for the Safari logo (which is the longest) as a SVG file, it comes out at 20KB! So, there really doesn't seem to be any reason for embedding those large, very detailed, SVG code lines in the component. |
@captainbrosset As for no-JS widget, Astro Embed As for SVG optimization, there is an excellent tool SVGOMG. |
Instead of trying to wrangle the SVGs, how well do base64-encoded small PNGs do? |
Agreed that the SVGs are unnecessarily complex. At most we're only going to be showing these icons somewhere between 30px to 200px. At these sizes, raster images seem to be perform a lot better. In my previous comment, I tested AVIF which (even for the largest page zoom) produced a 3KB file for the Safari logo. Someone should try to embed base64-encoded versions of these images and see what the result feels like. |
@captainbrosset As for AVIF, it's not widely supported, so I would stick with good old PNG. For comparison, here is the optimized PNG version of Safari logo (40x40 px, 2119 B): Base64 encoding of PNG in data URI adds an overhead of 33%. SVG does not need to be Base64-encoded. |
What about not including any images in the package itself? The data is fetched from an external endpoint anyways, so maybe the API server could also serve the logos? (In that case, maybe also allow an option to set the baseURL for the logos, so that people can self-host the logos if they want to) |
Posting from: https://bsky.app/profile/nullvoxpopuli.com/post/3l4g6z3holy27
After gzip, this library (+ dependencies) are 23kb.
This is quite hefty.
BundlePhobia: https://bundlephobia.com/package/[email protected]
Some of it is lit -- but a lot of it is just this component.
some questions:
Exports analysis is available only for packages that export ES Modules and are side-effect free.
This package [...] isn't marked side-effect free.
The text was updated successfully, but these errors were encountered: