This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
metalsmith-inline-svg with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
A metalsmith plugin that inlines svg images into your html to reduce the number of http requests.
Remember to be selective over which svgs you inline. If you inline svgs which appear on multiple pages you wont benefit from caching which you get with individually loaded files!
This plugin doesn't remove the svg files after as it does no checking to see if they're used elsewhere.
npm install metalsmith-inline-svg
var inlineSVG = require('metalsmith-inline-svg'); Metalsmith(__dirname) .use(inlineSVG()) .build()
<defs />tags. I had some issues where the
DOMParserwas not correctly closing empty
defstags so we strip them out. (default