# react-inject-script

> Dynamically inject `` to your react app html file. Benefit, we can load desired library on demand instead of load everything on start up.

Latest version **1.0.4** (published 2021-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-inject-script
pnpm add react-inject-script
yarn add react-inject-script
bun add react-inject-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.0.4 |
| Published | 2021-01-17 |
| First published | 2021-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | fattahmuhyiddeen |
| Keywords | dynamic, inject, script |

## Links

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

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2021-01-17
- 1.0.3 — 2021-01-17
- 1.0.2 — 2021-01-17
- 1.0.1 — 2021-01-17

## README

# react-inject-script

Dynamically inject `<script>` to your react app html file. Benefit, we can load desired library on demand instead of load everything on start up.

## Installation
`yarn add react-inject-script`

## Usage
```
import injectScript from 'react-inject-script';


.....

injectScript('any-unique-name', 'https://link.to.file/min.js').then(() => {
  setTimeout(() => console.log('Successfully loaded'), 1000);
})
.catch(e => {
  console.log(`Failed to load: ${e}`);
});


```
description

'any-unique-name' should be unique per project. this to prevent from the <script> is injected twice if the library is called more than 1

Source code is copied from here: https://www.linkedin.com/pulse/make-opencv-work-react-apps-james-shen

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