Skip to content

Conversation

@rodlie
Copy link
Member

@rodlie rodlie commented Nov 19, 2025

This will replace the external application 'SVGO' with our own implementation.

We don't want to be dependent on external (bloated) nodejs stuff just to "clean" our SVG.

This will replace the external application 'SVGO' with our own implementation.

We don't want to be dependent on external (bloated) nodejs stuff just to "clean" our SVG.

This function optimize any SVG "for the web" (aka production).
@rodlie rodlie added this to the 1.0.0 milestone Nov 19, 2025
Don't optimize if preview (HTML).
@pgilfernandez
Copy link

Cool!
This way it will work out of the box for all OSs.

I'm curious, what optimizations will be included? Will them be configurable?

@rodlie
Copy link
Member Author

rodlie commented Nov 19, 2025

I'm curious, what optimizations will be included? Will them be configurable?

Same as SVGO, https://github.com/friction2d/friction/blob/9414883a2b9569c3f90a10b0cbd732b1558d97d6/src/app/svgo.config.js

    removeXMLProcInst
    collapseGroups
    removeUselessDefs
    removeEmptyContainers

You can't configure anything, either on or off.

More features could be added, but not a priority (from me). The primary reason was to avoid using the svgo binary.

@pgilfernandez
Copy link

What about a space removal to end up with a shrink file, kinda what is commonly done with CSS?

@rodlie
Copy link
Member Author

rodlie commented Nov 19, 2025

We apply a simple "minify", removing whitespace etc.

No optimize:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Friction - https://friction.graphics -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1920 1080">
<rect width="1920" fill="#000000" height="1080"/>
<g transform="translate(5 5)">
<g transform="translate(704.303 342.681)">
<g>
<animateTransform attributeName="transform" calcMode="spline" keyTimes="0;0;1" dur="9.96667s" type="rotate" values="0;0;186.831" keySplines="0 0 1 1;0 0 1 1" repeatCount="indefinite"/>
<g transform="scale(1 1)">
<g transform="skewX(0) skewY(0)">
<g opacity="1" transform="translate(-5 -5)">
<rect x="0" y="0" stroke-linecap="round" id="RectangleBox" width="523.07" stroke-linejoin="round" fill="#6ce94f" stroke="none" rx="0" stroke-width="10" ry="0" fill-opacity="0.432197" height="366.616"/>
</g>
</g>
</g>
</g>
</g>
</g>
<defs/>
</svg>

Optimize:

<!-- Created with Friction - https://friction.graphics --><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 1920 1080"><rect width="1920" fill="#000000" height="1080"/><g transform="translate(5 5)"><g transform="translate(704.303 342.681)"><g><animateTransform attributeName="transform" calcMode="spline" keyTimes="0;0;1" dur="9.96667s" type="rotate" values="0;0;186.831" keySplines="0 0 1 1;0 0 1 1" repeatCount="indefinite"/><g opacity="1" transform="scale(1 1) skewX(0) skewY(0) translate(-5 -5)"><rect x="0" y="0" stroke-linecap="round" id="RectangleBox" width="523.07" stroke-linejoin="round" fill="#6ce94f" stroke="none" rx="0" stroke-width="10" ry="0" fill-opacity="0.432197" height="366.616"/></g></g></g></g></svg>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants