You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I recently ran scour to reduce size of these typst outputs (to save space in typst/packages). The following are ideas for reducing size of SVG outputs:
Use unique minimal ids
Typst 0.13.1 produces symbols with ids like id="gAE8F30B35D6A8EB54F09046949FB529D"and scour replaces it with id="n" and so on
This saved 8% file size on the two text filled tables
Unclear if viable for Typst
Use less indentation
Typst 0.13.1 produces 4-space indentation, consider 0-space, 1-space or no whitespace at all
Going from 4-space to no whitespace saves 5-10% on the tested files.
Use less coordinate precision
This is a lossy thing that scour does. It's probably not a good fit for Typst (?)
@Enivex iirc the IDs were indeed introduced because of incremental compilation (I want to say that they were introduced in one of the gradient PRs but frankly it's been too long). That being said, we might be able to rely on smaller hashes here? and manually detect collisions and do differentiation? That should work, right? Like use a 4-byte hash and then give them an extra byte if you have clashes 🤷♂
@Enivex iirc the IDs were indeed introduced because of incremental compilation (I want to say that they were introduced in one of the gradient PRs but frankly it's been too long). That being said, we might be able to rely on smaller hashes here? and manually detect collisions and do differentiation? That should work, right? Like use a 4-byte hash and then give them an extra byte if you have clashes 🤷♂
Is file size important enough for this though? For those who truly need minimal svgs there's always external tools like the one mentioned above.
Activity
MDLC01 commentedon May 31, 2025
At least part of this seems to be covered by #6247
Enivex commentedon May 31, 2025
Point 1: I don't think this is viable due to incremental compilation, but someone correct if I'm wrong.
Point 2: Using tabs instead of spaces for indentation would save some space without sacrificing human readability.
Point 3: I suspect this could introduce artifacts.
Dherse commentedon Jun 1, 2025
@Enivex iirc the IDs were indeed introduced because of incremental compilation (I want to say that they were introduced in one of the gradient PRs but frankly it's been too long). That being said, we might be able to rely on smaller hashes here? and manually detect collisions and do differentiation? That should work, right? Like use a 4-byte hash and then give them an extra byte if you have clashes 🤷♂
Enivex commentedon Jun 1, 2025
Is file size important enough for this though? For those who truly need minimal svgs there's always external tools like the one mentioned above.
bluss commentedon Jun 1, 2025
Just punting this to external tools seems fair enough to me. I can see how none of the suggestions really work out, except for indentation.
Enter-tainer commentedon Jun 6, 2025
whitespace and long id can be well compressed by gzip if one want to serve these svg on web.