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 xmlns attribute could be stripped when inside HTML documents #704

Closed
JRaspass opened this issue May 20, 2024 · 2 comments
Closed

SVG xmlns attribute could be stripped when inside HTML documents #704

JRaspass opened this issue May 20, 2024 · 2 comments

Comments

@JRaspass
Copy link

Note: The xmlns attribute is only required on the outermost svg element of SVG documents, or inside HTML documents with XML serialization. It is unnecessary for inner svg elements or inside HTML documents with HTML serialization.

https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg

So for minifcation of an entire HTML document we could strip the SVG xmlns attribute, e.g.

minify.HTML(...)
<!doctype html>

<html>
    <svg id="foo" viewBox="0 0 1 1" xmlns="http://www.w3.org/2000/svg">
        <rect width="1" height="1"/>
    </svg>

<!doctype html><html><svg id="foo" viewBox="0 0 1 1"><rect width="1" height="1"/></svg>
@tdewolff
Copy link
Owner

Nice one, thanks for sharing! This is now implemented.

@JRaspass
Copy link
Author

Works perfectly! Many thanks 👍

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