# script-injector

> Inject inline javascript into an HTML stream.

Latest version **1.0.0** (published 2015-04-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install script-injector
pnpm add script-injector
yarn add script-injector
bun add script-injector
```

## 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 | 1.0.0 |
| Published | 2015-04-13 |
| First published | 2013-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | David Manning |
| Maintainers | dlmanning |
| Keywords | html, stream, script, inject, injector, injection, parser |

## Links

- npm: https://www.npmjs.com/package/script-injector
- Repository: https://github.com/dlmanning/script-injector
- Issues: https://github.com/dlmanning/script-injector/issues
- npm.io page: https://npm.io/package/script-injector

## Dependencies (3)

- [trumpet](https://npm.io/package/trumpet.md) ^1.7.1
- [through2](https://npm.io/package/through2.md) ^0.6.5
- [duplexer2](https://npm.io/package/duplexer2.md) 0.0.2

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-04-13
- 0.1.7 — 2014-01-25
- 0.1.6 — 2013-10-19
- 0.1.5 — 2013-09-19
- 0.1.4 — 2013-08-30
- 0.1.3 — 2013-08-30
- 0.1.2 — 2013-07-21
- 0.1.1 — 2013-07-19
- 0.1.0 — 2013-07-09
- 0.0.1 — 2013-05-01

## README

#script-injector

1. provides a through stream that allows you to inject inline javascript into an html text stream.
2. Uses [`trumpet`](https://github.com/substack/node-trumpet) to parse your html.
3. Should only be used for good, never for evil

## Installation

`npm install script-injector`


## How to use

Just pipe a stream of html through script-injector. You can pass in either some stringified code or a function object. What could be easier?

```javascript
scriptInjector = require('script-injector');

// Then do something like this somewhere else

fs.createReadStream('anHTMLFile')
  .pipe(scriptInjector(aFunction))
  .pipe(someOtherPlace);
```

`script-injector` will insert the provided code *before* your first script tags, or just before `</body>` if you don't have any other scripts.

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