Skip to content

Conversation

@KTibow
Copy link
Contributor

@KTibow KTibow commented Dec 21, 2023

Sometimes there is a svg or a g that has a redundant attribute, like this:

<svg fill="red">
    <rect fill="blue"/>
    <circle fill="blue"/>
</svg>

These can be removed.
And sometimes the defaults are inefficient, like this:

<svg>
    <g fill="red">
        <path/>
        <rect fill="blue"/>
        <circle fill="blue"/>
    </g>
</svg>

The default can be changed to something more efficient. This PR does that.

* This would be even better if it moved attributes from/to svg, but I'm not sure if I should implement that.
* If the default-changing is too much, I'm fine removing everything except for the redundant attribute remover.

Results

Join this with #1894 for better performance on icon sets. On Isometric Madness compared to current SVGO, this does -3221 bytes without multipass and -4343 with.

@KTibow KTibow changed the title feat(moveElemsAttrsToGroup): remove attributes that are overriden by children feat(moveElemsAttrsToGroup): improve attribute flow Dec 21, 2023
KTibow and others added 6 commits December 27, 2023 21:12
- Keep removal of early return in moveElemsAttrsToGroup to allow processing single-child groups
- Remove docs/03-plugins/move-elems-attrs-to-group.mdx (moved to docs/04-plugins/)
- Fix comment and type annotation for attributes map

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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

Successfully merging this pull request may close these issues.

1 participant