# html-insert

> 页头页体插入css js 元数据

Latest version **1.0.1** (published 2017-08-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install html-insert
pnpm add html-insert
yarn add html-insert
bun add html-insert
```

## 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.1 |
| Published | 2017-08-08 |
| First published | 2017-08-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | lunzi |
| Maintainers | lunzi |
| Keywords | webpack, html-insert |

## Links

- npm: https://www.npmjs.com/package/html-insert
- Repository: git@git.coding.net:lunzi-/lunzishe
- npm.io page: https://npm.io/package/html-insert

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.16.2

## 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.0.1 (latest) — 2017-08-08
- 1.0.0 — 2017-08-08

## README

# html-insert
在html页面中注入代码

## Install

```
$ npm install --save html-insert
```


## Usage

```js
var htmlXXXInject = require('html-insert');

htmlXXXInject.assetsInject('<html><head><title>inject</title></head><body>some text...</body></html>', {
    assets: [
        {
            type: 'css',
            url: 'http://foo.com/bar.css',
            inject: 'head'
        },
        {
            type: 'js',
            url: 'http://foo.com/bar.js',
            inject: 'body'
        }
    ]
});
//=> '<html><head><title>inject</title><link rel="stylesheet" href="http://foo.com/bar.css" type="text/css" /></head><body>some text...<script type="text/javascript" src="http://foo.com/bar.js"></script></body></html>'
```

```js
htmlXXXInject.headMetaDataInject('<html><head><title>inject</title></head><body>some text...</body></html>', '<meta charset="utf-8">');
//=> '<html><head><title>inject</title><meta charset="utf-8"></head><body>some text...</body></html>'
```

## API

### assetsInject(htmlContent, options)

注入静态资源引用

#### htmlContent

Type: `string`


#### options

Type: `object`

### headMetaDataInject(htmlContent, metaData)

在head标签注入meta数据

#### htmlContent

Type: `string`

#### metaData

Type: `string`


## License

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