# html-inject-script

> Transform stream for injecting script tags into html.

Latest version **2.0.0** (published 2017-04-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install html-inject-script
pnpm add html-inject-script
yarn add html-inject-script
bun add html-inject-script
```

Provides the command `htmlinjectscript`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2017-04-21 |
| First published | 2015-08-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | kumavis |

## Links

- npm: https://www.npmjs.com/package/html-inject-script
- npm.io page: https://npm.io/package/html-inject-script

## Dependencies (2)

- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [hyperstream](https://npm.io/package/hyperstream.md) ^1.2.2

## Recent versions

- 2.0.0 (latest) — 2017-04-21
- 1.1.0 — 2015-09-11
- 1.0.0 — 2015-08-26

## README

# html-inject-script

Transform stream for injecting script tags into html.

### example:

```js
var injectScripts = require('html-inject-script')

process.stdin
.pipe( injectScripts(['./app.js', './extra.js']) )
.pipe( process.stdout )
```

input:
```html
<html><head></head><body>hello</body></html>
```
output:
```html
<html><head><script src="./app.js"></script><script src="./extra.js"></script></head><body>hello</body></html>
```

### api

#### `require('html-inject-script')(scripts[, opts])`

Injects an array of scripts. Accepts an object of options:
- `selector` (`string`, default: `'head'`): A [hyperstream](https://github.com/substack/hyperstream) selector into which the tags are injected
- `prepend` (`boolean`, default: `true`): If true, prepends. If false, appends.

### cli

```bash
cat index.html | htmlinjectscript "app.js" > output.html
```

```
usage: cat index.html | htmlinjectscript "app.js" > output.html

Options:

      --body  -b,  inject into the body element (default: head)

   --selector -s,  override head or body with a specific selector

     --append -a,  append to selector instead (default: prepend)

          --help,  -h  display this message
```

### Gotcha:
requires the tag (head, body, or otherwise) to be present in the src.

---
_Source: https://npm.io/package/html-inject-script · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
