# load-script-global

> Load a global library via a script tag

Latest version **1.0.4** (published 2019-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install load-script-global
pnpm add load-script-global
yarn add load-script-global
bun add load-script-global
```

## 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 | 2019-06-25 |
| First published | 2016-03-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ben Drucker |
| Maintainers | bendrucker |
| Keywords | load, global, script, browser |

## Links

- npm: https://www.npmjs.com/package/load-script-global
- Repository: https://github.com/bendrucker/load-script-global
- Homepage: https://github.com/bendrucker/load-script-global#readme
- Issues: https://github.com/bendrucker/load-script-global/issues
- npm.io page: https://npm.io/package/load-script-global

## Dependencies (8)

- [ear](https://npm.io/package/ear.md) ~1.0.1
- [cuid](https://npm.io/package/cuid.md) ~2.1.4
- [xtend](https://npm.io/package/xtend.md) ~4.0.1
- [global](https://npm.io/package/global.md) ~4.4.0
- [dezalgo](https://npm.io/package/dezalgo.md) ~1.0.3
- [assert-ok](https://npm.io/package/assert-ok.md) ~1.0.0
- [load-script](https://npm.io/package/load-script.md) ~1.0.0
- [query-extend](https://npm.io/package/query-extend.md) ~0.2.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2019-06-25
- 1.0.3 — 2018-02-06
- 1.0.2 — 2016-05-24
- 1.0.1 — 2016-03-05
- 1.0.0 — 2016-03-02

## README

# load-script-global [![Build Status](https://travis-ci.org/bendrucker/load-script-global.svg?branch=master)](https://travis-ci.org/bendrucker/load-script-global) [![Greenkeeper badge](https://badges.greenkeeper.io/bendrucker/load-script-global.svg)](https://greenkeeper.io/)

> Load a global library via a script tag


## Install

```
$ npm install --save load-script-global
```


## Usage

```js
var load = require('load-script-global')

load({
  url: 'https://maps.googleapis.com/maps/api/js?key=k',
  global: 'google',
  jsonp: true
}, function (err, google) {
  //=> google.Maps...  
})
```

* Attempting to load once the library is already available will avoid creating a new `<script>` tag but still call the callback with the library
* Attemtping to load the library multiple times in a row will only create a single script tag and still calls each callback

## API

#### `load(options, callback)` -> `undefined`

##### options

*Required*  
Type: `object`

###### url

*Required*  
Type: `string`

The script URL.

###### global

*Required*  
Type: `string`

The name of the window global that the script will publish.

###### jsonp

Type: `boolean`

If `true`, listens for success via a JSONP callback instead of on `script.onload`.

##### callback

*Required*  
Type: `function`  
Arguments: `err, library`

A callback that will be called with a loading error or the library as published on the window once available.

## License

MIT © [Ben Drucker](http://bendrucker.me)

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