Skip to content
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

feat: generate svg sprite from used icons #55

Open
dominikg opened this issue Sep 15, 2021 · 4 comments
Open

feat: generate svg sprite from used icons #55

dominikg opened this issue Sep 15, 2021 · 4 comments

Comments

@dominikg
Copy link

just something that popped into my head a minute ago

  • collect all referenced icons into one svg sprite with ids for each (maybe one sprite per collection to avoid id clashes or prefixed-ids)
  • instead of the real icon svg return a wrapper that references the id with xlink:href

would save some for icons that are used repeatedly

@Akryum
Copy link
Contributor

Akryum commented Sep 15, 2021

I'm not sure it would actually save bytes, since you import the same component for each icon.

@dominikg
Copy link
Author

This is not only about transferred bytes but also about rendering on the client.
There is a tradeoff to be made between inlining the same svg multiple times or just having multiple references to the same item in a sprite. Also the svg sprite would be an asset, whereas generated components are weighing in on js bundle size.

This is not a slam dunk improvement for every situation, but it could be useful in some.

@IanVS
Copy link
Contributor

IanVS commented Sep 16, 2021

If it's not inline, don't you lose the ability to style the svg with css? I haven't done this with href before though (it seems xlink:href is deprecated).

@Akryum
Copy link
Contributor

Akryum commented Sep 16, 2021

I know that with <use xlink:href="..."> you can style the SVG with CSS. Not sure about href though.

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

No branches or pull requests

3 participants