Injects CSS and JS asset tags into a HTML document

HTML Asset Tag Injector

Injects asset tags (e.g. <script> and <link>) inside a given HTML document in the most optimal place.

Outputs original HTML with top tags (typically CSS) and bottom tags (typically JS) correctly inserted.

var injector = require('html-tag-injector');
var input = fs.readFileSync('any.html', 'utf8');
var output = injector(input, {
  top:    '<link rel="stylesheet" type="text/css" href="my.css">'
  bottom: '<script type="text/javascript" src="/myscript.js">'

This module is a work in progress. It's possible we'll need to move to a real HTML parser (like htmlparser2) instead of simple string substation in the future.

Pull requests appreciated. Please be sure to create test cases (it's easy).

To run tests: