# script-loader-async

> Async script loader

Latest version **1.0.0** (published 2019-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install script-loader-async
pnpm add script-loader-async
yarn add script-loader-async
bun add script-loader-async
```

## 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 | 2019-04-28 |
| First published | 2019-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Nazim Jamil-Mir |
| Maintainers | njamil |

## Links

- npm: https://www.npmjs.com/package/script-loader-async
- Repository: https://github.com/nazimjamil/async-script-loader
- Homepage: https://github.com/nazimjamil/async-script-loader#readme
- Issues: https://github.com/nazimjamil/async-script-loader/issues
- npm.io page: https://npm.io/package/script-loader-async

## Recent versions

- 1.0.0 (latest) — 2019-04-28

## README

# Async Script Loader

[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

> This tiny util allows you to dynamically load a script into the global scope.

### Usage
Call `loadScript` with the three required parameters:
  * `namespace` e.g. if the script is accessible via `window.coolUtil` the namespace is `coolUtil`
  * `url`
  * `callback` function - this recieves the promise which will either resolve or reject and a `cancelSource` token if you need to abort the request.
  * `window` object

#### Example
```
// import the util
import loadScript from 'async-script-loader;

// define your callback function
const callbackFn = (response) => {
  // if successful the script will be available in the global scope under the namespace you provided

  // if unsuccessful the error message is returned
}

// do the thing
loadScript('coolUtil', 'https://coolutil.com', window, callbackFn);

```

* Backed by tests in [Jest](https://jestjs.io/)
* Typed with [FlowType](https://flow.org)
* Linted with [ESLint](https://eslint.org)
* PR's welcome
* API improvements welcome

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