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

Setting innerHTML is slow #25

Open
aminya opened this issue Jan 17, 2023 · 2 comments · May be fixed by #28
Open

Setting innerHTML is slow #25

aminya opened this issue Jan 17, 2023 · 2 comments · May be fixed by #28

Comments

@aminya
Copy link
Contributor

aminya commented Jan 17, 2023

I am using solid-icons with Solid-start. However, I have noticed that innerHTML is set on the client side using JavaScript. This is slow when many icons are used on a website based on the real-world profiling I have done.

https://github.com/x64Bits/solid-icons/blob/8805c0198e68872903f01587ce66143853b513b7/src/lib/index.tsx#LL38C7-L38C16

One suggestion would be to import the string of the SVG file and use it as the src attribute for the img tag. Vite and some other build tools are very smart for inlining these strings during compile-time.

Are there any other ways to improve this?

@aminya
Copy link
Contributor Author

aminya commented Jan 22, 2023

I have fixed this in my fork @aminya/solid-icons. I can upstream the changes once the other PRs are merged
https://github.com/aminya/solid-icons/

@aminya aminya linked a pull request Feb 1, 2023 that will close this issue
@nathanbabcock
Copy link

One suggestion would be to import the string of the SVG file and use it as the src attribute for the img tag.

Using icons like this would lose the ability to dynamically recolor with CSS, for example on the theme color toggle shown in the demo app where it inherits fill="currentColor".

I wanted to double check that your PR doesn't eliminate this functionality since it's an important feature I rely on. But I am assuming it is provided in a way that allows for either usage, both <img src="..."> and as an inline <svg> element while also improving performance & reducing build time.

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 a pull request may close this issue.

2 participants