How to svg unused defs purger: edge cases, limitations, and faq
- Step 1Identify external CSS dependencies — Search your CSS files for SVG id references: grep -r 'url(#' ./src/css. Any id found there should be added to the preserve list before purging.
- Step 2Check for JavaScript-referenced ids — Search for SVG ids referenced in JavaScript: grep -r 'getElementById\|querySelector' ./src/js | grep '#'. Add these to the preserve list too.
- Step 3Run with preserve list enabled — In the tool settings, enter all externally-referenced ids in the Preserve IDs field, comma-separated. Then run the purge — only truly unused defs will be removed.
Frequently asked questions
Can the purger detect ids referenced in external CSS files?+
No — the purger only analyses the SVG document itself. Ids referenced from external stylesheets or JavaScript must be manually added to the preserve list.
How are animated SVG defs handled?+
SMIL animations that modify fill or filter attributes using url(#id) references are detected correctly. CSS animation keyframes that reference SVG ids need the external CSS caveat above.
What happens with nested SVG documents?+
The purger analyses the outermost SVG document. Nested <svg> elements are treated as children — their internal defs are scanned but only checked against the outermost document's reference pool.
What is the maximum SVG complexity the purger handles?+
The purger has been tested on SVGs with 10,000+ elements. Performance degrades linearly — a 5 MB SVG with complex defs may take 3–5 seconds to analyse in the browser.
Privacy first
Every JAD SVG tool runs entirely in your browser using the DOM API and Canvas. Your SVG files never leave your device — verified by zero outbound network requests during processing.