How to automate svg optimisation in your github actions pipeline
- Step 1Install the SVGO CLI — Add svgo to your project's devDependencies: npm install --save-dev svgo. This gives you the CLI available in any CI runner.
- Step 2Add a workflow step — In your .github/workflows/build.yml, add a step that runs: npx svgo --recursive --folder ./public/icons. This minifies all SVGs in place before the build step.
- Step 3Commit and verify — Push to a feature branch and check the Actions log. You should see file size reductions reported. Add a size-limit check to fail the build if any SVG exceeds your threshold.
Frequently asked questions
Does SVGO CLI produce the same output as the browser tool?+
Yes, when configured with the same plugin set. JAD's browser tool uses the same SVGO core as the CLI — you can export the config and use it with the CLI for consistent results.
How do I prevent SVGO from changing SVG IDs used in CSS?+
Set the cleanupIds plugin to false in your svgo.config.js. This preserves all id attributes, preventing SVGO from renaming selectors referenced in your stylesheets.
Can I use the JAD API in CI/CD?+
Yes. Pro and Developer plan subscribers have API access. POST your SVG to /api/svg/minify with your API key and receive the optimised SVG in the response body.
How do I fail the build if an SVG is too large after minification?+
Pipe the output through a size check: if the output file is larger than your threshold (e.g., 20KB), exit with a non-zero code. The bundlesize or size-limit npm packages can automate this check.
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.