You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
break(svgr): remove XML namespaces of inline SVGs by default - #13005
The default SVGO config of @docusaurus/plugin-svgr now removes the XML namespaces of inline SVGs (SVG files imported as React components), which browsers ignore in HTML:
removeXlink (with includeLegacy: true) replaces xlink:href with href and removes the xmlns:xlink declaration.
mergePaths uses noSpaceAfterFlags: true to write slightly shorter path data.
Who is affected: sites whose CSS or JS targets these attributes inside inline SVGs (like [xlink\:href] selectors). The rendering of the SVGs doesn't change.
How to restore the previous behavior: provide an svgrConfig.svgoConfig without these plugins (see the default config).
Motivation
These are the remaining suggestions of the SVGO maintainer in #10679, used on svgo.dev. SVGO disables them by default because they can break SVGs opened as standalone files (image viewers, editors), but they are safe for SVGs inlined in HTML, which is what SVGR outputs. The prefixIds part of the suggestion already landed in #12690.
Benchmark
SVGR output of the 21 SVGs of our website: 370,186 → 369,191 bytes (-995 bytes, -0.27%), mostly from xmlns attributes.
Test Plan
One unit test per setting, running the real SVGR + SVGO pipeline: xmlns is removed, xlink:href becomes href (including on the legacy <filter> element, thanks to includeLegacy), and merged arc paths have no spaces after their flags. Each test fails when its setting is disabled.
Argos: inline SVGs of the dogfood page render identically (no screenshot diff on /tests/pages/svg). The only screenshot diff is the longer default config on the plugin docs page.
Accessibility bonus: Chromium doesn't expose <a xlink:href> as links in its accessibility tree. With href, the 2 links of integrations.svg now appear in the Argos aria snapshot of /tests/pages/svg. Checked on docusaurus.io (main) vs the deploy preview: the links resolve in both.
slorber
added
pr: breaking change
Existing sites may not build successfully in the new version. Description contains more details.
Argos
Add this label to run UI visual regression tests. See argos.yml GH action.
labels
Nov 12, 2026
No actionable comments were generated in the recent review.
Walkthrough
The SVGR loader's default SVGO configuration now enables path merging and XML namespace removal. Tests check transformed SVG output, and the plugin documentation describes the updated options.
Changes: SVGR default configuration
Layer / File(s)
Summary
Update and verify default SVGO options packages/docusaurus-plugin-svgr/src/svgrLoader.ts, packages/docusaurus-plugin-svgr/src/__tests__/svgrLoader.test.ts, website/docs/api/plugins/plugin-svgr.mdx
The default configuration sets mergePaths.noSpaceAfterFlags to true and enables removeXlink with legacy handling and removeXMLNS. Tests check that transformed SVG output omits xmlns, converts XLink references to href on <use> and legacy <filter> elements while retaining prefixed references, and omits spaces after arc flags in merged paths. The documentation describes the options and their effect on inline SVGs.
The default inline SVG optimization now strips XML namespaces and converts xlink:href to href. Rendering is reported unchanged. Sites that target these attributes with CSS or JavaScript can restore the old behavior with a custom SVGO config. No merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: breaking default SVGR/SVGO behavior so that inline SVGs have XML namespaces removed. The changeset adds removeXMLNS and removeXlink (includeLegacy) plugins to the defa…
Linked Issues check
[#10679] asks for better SVGR/SVGO defaults that suit most sites, reduce custom configuration, and use safe optimizations that avoid SVG id and class conflicts. The source diff at head confirms the de…
Out of Scope Changes check
The source diff at head touches only packages/docusaurus-plugin-svgr/src/svgrLoader.ts, its test file svgrLoader.test.ts, and the plugin-svgr API documentation (website/docs/api/plugins/plugin-svgr.md…
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title names the main change: breaking default SVGR/SVGO behavior so that inline SVGs have XML namespaces removed. The changeset adds removeXMLNS and removeXlink (includeLegacy) plugins to the default SVGO config, enables mergePaths noSpaceAfterFlags, updates the docs, and adds tests. The title uses the breaking-change prefix and is concise. The title omits the xlink:href conversion and the mergePaths change, which is acceptable because it does not need to cover every detail.
Full details: Linked Issues check
Explanation
[#10679] asks for better SVGR/SVGO defaults that suit most sites, reduce custom configuration, and use safe optimizations that avoid SVG id and class conflicts. The source diff at head confirms the default config change in packages/docusaurus-plugin-svgr/src/svgrLoader.ts (createDefaultSVGOConfig): mergePaths with noSpaceAfterFlags: true is added to the preset overrides, and removeXlink (includeLegacy: true) and removeXMLNS are appended to the plugins. The new tests in svgrLoader.test.ts cover xmlns removal, xlink:href to href conversion on use and filter elements with prefixed ids retained, and the noSpaceAfterFlags path output. The issue does not list specific plugins as acceptance criteria. The prefixIds change was already merged in #12690 and is not claimed here. The issue remains open for broader review of defaults, which this PR does not need to complete. Non-coding claims (Argos diffs, aria snapshot, deploy preview checks) were not used for this verdict.
Full details: Out of Scope Changes check
Explanation
The source diff at head touches only packages/docusaurus-plugin-svgr/src/svgrLoader.ts, its test file svgrLoader.test.ts, and the plugin-svgr API documentation (website/docs/api/plugins/plugin-svgr.mdx, per the summary). All changes implement the default SVGO config change described in the PR. The test additions verify that change. The documentation describes the new default behavior and the restore path. The mergePaths noSpaceAfterFlags setting is part of the same default config, and the PR states its size benefit. No unrelated file or behavior change appears in the reviewed diffs. The docs file was not read directly, so its content is supported by the summary only.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArgosAdd this label to run UI visual regression tests. See argos.yml GH action.CLA SignedSigned Facebook CLApr: breaking changeExisting sites may not build successfully in the new version. Description contains more details.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking Changes
The default SVGO config of
@docusaurus/plugin-svgrnow removes the XML namespaces of inline SVGs (SVG files imported as React components), which browsers ignore in HTML:removeXMLNSremoves thexmlnsattribute.removeXlink(withincludeLegacy: true) replacesxlink:hrefwithhrefand removes thexmlns:xlinkdeclaration.mergePathsusesnoSpaceAfterFlags: trueto write slightly shorter path data.Who is affected: sites whose CSS or JS targets these attributes inside inline SVGs (like
[xlink\:href]selectors). The rendering of the SVGs doesn't change.How to restore the previous behavior: provide an
svgrConfig.svgoConfigwithout these plugins (see the default config).Motivation
These are the remaining suggestions of the SVGO maintainer in #10679, used on svgo.dev. SVGO disables them by default because they can break SVGs opened as standalone files (image viewers, editors), but they are safe for SVGs inlined in HTML, which is what SVGR outputs. The
prefixIdspart of the suggestion already landed in #12690.Benchmark
SVGR output of the 21 SVGs of our website: 370,186 → 369,191 bytes (-995 bytes, -0.27%), mostly from
xmlnsattributes.Test Plan
xmlnsis removed,xlink:hrefbecomeshref(including on the legacy<filter>element, thanks toincludeLegacy), and merged arc paths have no spaces after their flags. Each test fails when its setting is disabled./tests/pages/svg). The only screenshot diff is the longer default config on the plugin docs page.<a xlink:href>as links in its accessibility tree. Withhref, the 2 links ofintegrations.svgnow appear in the Argos aria snapshot of/tests/pages/svg. Checked on docusaurus.io (main) vs the deploy preview: the links resolve in both.Test links
Deploy preview: https://deploy-preview-13005--docusaurus-2.netlify.app/
Related issues/PRs
Fixes #10679
🤖 Generated with Claude Code
Summary by CodeRabbit
Improvements
xmlnsattributes and convert legacyxlink:hrefreferences tohref, while preserving prefixed references.Documentation