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

Please establish lossless and secure compression as the primary idea #1360

Closed
2 of 3 tasks
yisibl opened this issue Feb 22, 2021 · 5 comments
Closed
2 of 3 tasks

Please establish lossless and secure compression as the primary idea #1360

yisibl opened this issue Feb 22, 2021 · 5 comments

Comments

@yisibl
Copy link
Contributor

yisibl commented Feb 22, 2021

As an svg compressor, I think it is most important not to change the display effect of the svg itself, which means that the compressed result cannot change the shape, position, size, color, etc. (svgcleaner has a detailed description). As svgo is adopted by more and more non-browser terminals (Sketch, Adobe Illustrator, other back-end languages), this will become more and more difficult, because each side implements svg differently. So we urgently need to introduce Correctness test like svgcleaner to help svgo become the best svg compressor.

The following work is a good start:

cc @deepsweet

@sk-
Copy link
Contributor

sk- commented Feb 22, 2021

May I add that we should change the default options to only include those plugins known/supposed to be lossless. For example convertPathData probably should not be a default plugin unless the default options are safe. I've also seen that gradients are usually changed.

@TrySound
Copy link
Member

Or we should make it safe.

TrySound added a commit that referenced this issue Feb 22, 2021
Ref #1362 #1360

From the [spec](https://www.w3.org/TR/SVG11/styling.html#UsingPresentationAttributes):

> Presentation attributes have lower priority than other CSS style rules specified in author style sheets or ‘style’ attributes.

Though we replace inline styles with attributes without checking if
thare is any `<style>` element. This makes the plugin unsafe and it
should not be enabled by default.
TrySound added a commit that referenced this issue Feb 22, 2021
Ref #1362 #1360

From the [spec](https://www.w3.org/TR/SVG11/styling.html#UsingPresentationAttributes):

> Presentation attributes have lower priority than other CSS style rules specified in author style sheets or ‘style’ attributes.

Though we replace inline styles with attributes without checking if
thare is any `<style>` element. This makes the plugin unsafe and it
should not be enabled by default.
@mischnic
Copy link

Another case here is cleanupIds, which is generally good, unless you use something like <use xlink:href="square.svg#square" x="20" fill="white" stroke="red"/> where removing the IDs inside square.svg isn't safe.

@TrySound
Copy link
Member

We have now presets concept. I'm ok to implement different presets. Though would be good if somebody explore all plugins.
I'm currently busy preparing svgo 3.

@SethFalco
Copy link
Member

Closing this as we're now actively striving for this, but the issue isn't presented in a way that we can track progress and know when it's complete.

If you have concrete suggestions, you're encouraged to open another issue with what we can specifically do better. Meanwhile, I'm not at all dismissing the issue.

All future development is done with lossless compression in mind. We're investing a lot of time and effort in fixing bugs, improving testing, and having more complete documentation to clarify potential quirks. I'm also working on new sections to include in the documentation to clarify what we optimize, and in what cases we may deem something more important than reducing bytes.

In recent released, I believe we've already made good progress, and will continue to do so. 👍🏽

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

5 participants