
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
grunt-svginjector
Advanced tools
Inject external SVG files into HTML
grunt-svginjector is a Grunt plugin that allows you to inline SVGs into your HTML by way of a generated JavaScript file. It works great in conjunction with grunt-svgstore for using SVG icons.
Read this article to see how I'm using it.
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-svginjector --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-svginjector');
svginjector taskRun this task with the grunt svginjector command.
containerType: String
Default: #svginjector
The ID of the element into which to inject the SVGs.
modeType: String
Default: replace
The mode option controls how the SVG is inserted into the DOM. Possible values:
replace replaces the content of the DOM element;append adds the SVG as the last child of the DOM element;prepend adds the SVG as the first child of the DOM element.A quick example (see the example folder for more input/output examples):
grunt.initConfig({
svginjector: {
example: {
options: {
container: '#icons-container'
},
files: {
'example/dist/icons.js': 'example/src/icons.svg'
}
}
}
});
FAQs
Inject SVGs into HTML pages
The npm package grunt-svginjector receives a total of 45 weekly downloads. As such, grunt-svginjector popularity was classified as not popular.
We found that grunt-svginjector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.