# replace-html-script

> replaces the content of the script-tag with a given file

Latest version **1.1.1** (published 2019-05-15) · MIT license · 0 weekly downloads

## Install

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

## 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.1.1 |
| Published | 2019-05-15 |
| First published | 2019-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 25.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Martin Lümkemann |
| Maintainers | xhronos |
| Keywords | html, script, script-tag, script-element, polymer, polymer2, web-component, web-components, replace |

## Links

- npm: https://www.npmjs.com/package/replace-html-script
- Repository: https://github.com/xhronos/replace-html-script
- Homepage: https://github.com/xhronos/replace-html-script#readme
- Issues: https://github.com/xhronos/replace-html-script/issues
- npm.io page: https://npm.io/package/replace-html-script

## Dependencies (2)

- [fs-extra](https://npm.io/package/fs-extra.md) ^8.0.0
- [parse5-html-rewriting-stream](https://npm.io/package/parse5-html-rewriting-stream.md) ^5.1.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2019-05-15
- 1.0.1 — 2019-05-13
- 1.0.0 — 2019-05-13

## README

# replace-html-script

[![Build Status via Travis CI](https://travis-ci.org/xhronos/replace-html-script.svg?branch=master)](https://travis-ci.org/xhronos/replace-html-script)

Replaces the script tag in html files with the content of a script-file.
Works also on html-imports which are not well formed html documents since they
are missing the surrounding `<html>`, `<head>` / `<body>` tags.

There are two possible usages:
* as tool, e.g. for incorporating into a build process
* as node.js module


## Install

*install as globally installed tool*

```bash
npm install -g replace-html-script
```

*install to local node_modules folder*

```bash
npm install --save replace-html-script
```

## Usage

### command line

#### using pipes

```bash
cat input.html | replace-html-script -s scriptfile.js > output.html
```

### using file parameters

```bash
replace-html-script -s scriptfile.js -i input.html -o output.html
```

### node.js module

The `input` and `script` parameters can be either a filename or a ReadableStream.
The `output` parameter can also be either a filename or a WritableStream.

#### using filenames

```javascript
const { replaceScript } = require('replace-html-script');

const input = 'input.html';
const output = 'input.html';
const script = 'scriptfile.js';

replaceScript({input, output, script})
.then(()=>console.log("done"));
```

#### using streams

```javascript
const { replaceScript } = require('replace-html-script');
const fs = require('fs');

const input = fs.createReadStream('input.html');
const output = fs.createWriteStream('input.html');
const script = fs.createReadStream('scriptfile.js');

replaceScript({input, output, script})
.then(()=>console.log("done"));
```

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