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
perf(image): reduce svgo precision for tracedSVGs #4270
perf(image): reduce svgo precision for tracedSVGs #4270
Conversation
Looks almost identical! Really nice catch! @fk look good? |
Deploy preview for gatsbygram ready! Built with commit a320132 |
Lookin' veeeerrrrrry good! /cc @EmilTholin I think you might be interested in that change to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🎉
Holy smokes. That's a very nice find! Thank you @axe312ger, and thanks for the ping @fk! Before: 12657B, 6046B, 15526B, 22795B After: 5502B, 2993B, 6532B, 8171B This might also be a great PR to sqip, which you used in your other PR @axe312ger, if I'm not mistaken? |
Wow cool! Great previews :) Regarding the sqip svgo tweak: The effect is way less since it does not use paths and, with a quick test via svgo website, it actually has visible impact on the colors (🤷♂️ ) and slightly the positions of shapes. But I could imagine the sqip mode is impacting this a lot. |
Chrome audit resultsThis was kind of single run, don't take the numbers to serious. Pages were served locally via https://github.com/zeit/serve which I assume is optimized to imitate a production environment. I wonder why old gatsbygram with
|
gatsby-image lazy loads images so images won't load until JS is in which does slow down the initial load of images. We actually should add a prop that lets you disable lazy loading of certain images during SSR (but would lazy load still in the client) for exactly this reason — if an image loading is the critical path for a page, you could simply specify that image as not-lazy. One thing I worry about with gatsby-image is people sometimes think it's a drop-in replacement for the regular img tag. While it often is, it does make tradeoffs you might not want e.g. here. |
Thanks for finding this and PRing it in! |
While comparing initial html rendering results with different techniques, I found out traced SVG sizes can be reduced by the factor of ~2,2. It even increases the compression rate.
I tried several additional svgo settings but the only one with an higher reduction as 0.01% was to reduce the precision from 1 to 0
Example
My example data is based on gatsbygram which contains 12 traced svg previews.
Download index.html files of all tests
Compare to other initial rendering image preview techniques
Original - 313.0kB
Optimized - 150.8kB