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

chore: Optimize SVGs with the latest svgo (v3.2.0) #1037

Merged
merged 3 commits into from
Apr 17, 2024
Merged

chore: Optimize SVGs with the latest svgo (v3.2.0) #1037

merged 3 commits into from
Apr 17, 2024

Conversation

XhmikosR
Copy link
Contributor

@XhmikosR XhmikosR commented Apr 16, 2024

The order of attributes is what svgo is producing.

Copy link

vercel bot commented Apr 16, 2024

@XhmikosR is attempting to deploy a commit to the Package Phobia Team on Vercel.

A member of the Team first needs to authorize it.

@XhmikosR XhmikosR marked this pull request as ready for review April 16, 2024 18:38
Copy link

vercel bot commented Apr 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
packagephobia ✅ Ready (Inspect) Visit Preview Apr 17, 2024 6:31pm

@@ -120,7 +120,7 @@ export default () => (
viewBox="100 120 300 300"
>
<title>Vercel Logo</title>
<path fill="#fff" d="M254 156.459L367 356H141z" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does removing the "L" actually change the size? I would expect that to be the same as a space (1 byte).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get into the internals of SVGO, it's just an optimization the newer version has.

@@ -1,4 +1,4 @@
export default (id: string) => {
//const id = Math.random().toString().slice(2)
return `<svg xmlns="http://www.w3.org/2000/svg" width="108" height="108"><defs><linearGradient id="${id}"><stop offset="0" stop-color="#006838"/><stop offset="1" stop-color="#32de85"/></linearGradient></defs><path xmlns="http://www.w3.org/2000/svg" fill="url(#${id})" d="M21.667 73.809V33.867l28.33-16.188 28.337 16.188V66.13L49.997 82.321 35 73.75V41.604l14.997-8.57L65 41.604v16.788l-15.003 8.571-1.663-.95v-16.67l8.382-4.792-6.719-3.838-8.33 4.763V69.88l8.33 4.762 21.67-12.383V37.737l-21.67-12.379-21.663 12.379v39.88L49.997 90 85 70V30L49.997 10 15 30v40z" transform="matrix(1.25 0 0 1.25 -8.75 -7.5)"/></svg>`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be the exact same number of bytes

<path fill="currentColor" d="M128.3 109c-14.5-9.3-9.3-19.4-9.3-19.4 3-6.9 1.5-11 1.5-11-1.3-6.6 2.9-2.3 2.9-2.3 3.9 4.6 2.1 11 2.1 11-2.6 10.3 5.1 14.6 8.9 15.9" style="transform-origin:130px 106px" class="octo-arm"/>
<svg width="80" height="80" fill="#202420" aria-hidden="true" color="#fff" style="position:absolute;top:0;border:0;right:0" viewBox="0 0 250 250">
<path d="m0 0 115 115h15l12 27 108 108V0z"/>
<path fill="currentColor" d="M128.3 109c-14.5-9.3-9.3-19.4-9.3-19.4 3-6.9 1.5-11 1.5-11-1.3-6.6 2.9-2.3 2.9-2.3 3.9 4.6 2.1 11 2.1 11-2.6 10.3 5.1 14.6 8.9 15.9" class="octo-arm" transform-origin="130px 106px"/>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this changing anything? It looks identical.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not the same; CSS styles are moved to attributes.

@XhmikosR XhmikosR marked this pull request as draft April 17, 2024 05:34
@XhmikosR
Copy link
Contributor Author

Converted to draft because I need to redo the upstash logo.

@XhmikosR XhmikosR marked this pull request as ready for review April 17, 2024 15:28
@styfle
Copy link
Owner

styfle commented Apr 17, 2024

You don't need to force push. I squash on merge so the commits wont matter.

@XhmikosR
Copy link
Contributor Author

XhmikosR commented Apr 17, 2024

I'm just used to it, sorry.

Took me a while, it was that fillOpacity attribute.

Now everything should look the same.

EDIT:

Before: 38.34 kB / 24.95 kB transferred
After: 33.90 kB / 23.28 kB transferred

@styfle
Copy link
Owner

styfle commented Apr 17, 2024

The logo color looks wrong for upstash.

Before After
image image

@XhmikosR
Copy link
Contributor Author

I tested it live on the browser and hopefully now it should be fine.

@styfle styfle merged commit e7f60c9 into styfle:main Apr 17, 2024
4 checks passed
@XhmikosR XhmikosR deleted the xmr/svg-opt branch April 17, 2024 18:43
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.

2 participants