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

SVG optimization with tools like svgo #195

Open
feO2x opened this issue Jan 6, 2024 · 2 comments
Open

SVG optimization with tools like svgo #195

feO2x opened this issue Jan 6, 2024 · 2 comments

Comments

@feO2x
Copy link

feO2x commented Jan 6, 2024

Hi @Niels-IO,

first of all, thanks for all your efforts with next-image-export-optimizer. It’s an excellent tool.

I have one question regarding support for SVGs: do you plan to support optimization with tools like svgo? The use case is the following: I have an unoptimized SVG image that was created by a design tool like Adobe Illustrator or Xara Designer Pro X and simply copy it into my NextJS project. next-image-export-optimizer could then use a tool like svgo internally to optimize the image, usually reducing the SVG size by 30% to 70%:

svgo ./app/header/home-logo.svg -o ./app/header/home-logo-min.svg

home-logo.svg:
Done in 59 ms!
20.011 KiB - 60.5% = 7.912 KiB

Currently, I manually optimize SVGs with svgo and then utilize the pass-through functionality of next-image-export-optimizer for SVGs. Automating this process would be highly beneficial.

I'm also writing this because in one of the future versions, you plan to optimize SVG images to WebP or leave them unprocessed (#184), which is a breaking change. IMO, the default use case should be optimizing the SVG image and leave it in the same format as vector graphics tend to be smaller than rasterized images (even if webp is awesome when it comes to compression vs. image quality).

I would let the end user decide if they want to optimize an SVG to webp (via a global setting and/or per-image). The default setting would optimize the SVG with svgo, but would not change the format. This way, you would not introduce a breaking change, there would only be one optimized SVG file per image that is served for all requested sizes (we wouldn't need a source set for this). And users could opt in when they really want to convert SVGs to webp images.

I look forward to your thoughts on this.

Have a great day,
feO2x

@Niels-IO
Copy link
Owner

Niels-IO commented Jan 7, 2024

Hi @feO2x,

This is an interesting idea! I never heard of this package. What is your experience with the quality of the output from svgo? Will there be artifacts or any other misrepresentations of the original shape?

@feO2x
Copy link
Author

feO2x commented Jan 7, 2024

I've never had any issues - artifacts should not be a problem at all because vector graphics usually do not contain rasterized elements. I also have never experienced any deformed/changed elements. svgo mostly removes white space and simplifies elements.

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

2 participants