Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fisker/browser-load-script
Load script in browser.
https://github.com/fisker/browser-load-script
Last synced: 6 days ago
JSON representation
Load script in browser.
- Host: GitHub
- URL: https://github.com/fisker/browser-load-script
- Owner: fisker
- License: mit
- Created: 2022-03-17T05:57:19.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-03T00:15:46.000Z (13 days ago)
- Last Synced: 2024-11-07T03:49:40.629Z (9 days ago)
- Language: JavaScript
- Size: 1.1 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# browser-load-script
[![Build Status][github_actions_badge]][github_actions_link]
[![Coverage][coveralls_badge]][coveralls_link]
[![Npm Version][package_version_badge]][package_link]
[![MIT License][license_badge]][license_link][github_actions_badge]: https://img.shields.io/github/workflow/status/fisker/browser-load-script/CI/main?style=flat-square
[github_actions_link]: https://github.com/fisker/browser-load-script/actions?query=branch%3Amain
[coveralls_badge]: https://img.shields.io/coveralls/github/fisker/browser-load-script/main?style=flat-square
[coveralls_link]: https://coveralls.io/github/fisker/browser-load-script?branch=main
[license_badge]: https://img.shields.io/npm/l/browser-load-script.svg?style=flat-square
[license_link]: https://github.com/fisker/browser-load-script/blob/main/license
[package_version_badge]: https://img.shields.io/npm/v/browser-load-script.svg?style=flat-square
[package_link]: https://www.npmjs.com/package/browser-load-script> Load script in browser.
## Install
```bash
yarn add browser-load-script
```## Usage
```html
{
"imports": {
"browser-load-script": "https://unpkg.com/browser-load-script"
}
}import loadScript from 'browser-load-script'
await loadScript('data:application/javascript,')
```
## API
### `loadScript(sourceOrProperties)`
```js
import loadScript from 'browser-load-script'await loadScript('https://example.com/script.js')
```#### `sourceOrProperties`
- Type: `string | Object`
[Available properties](https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement#instance_properties)
```js
import loadScript from 'browser-load-script'await loadScript({
src: 'https://example.com/script.js',
defer: true,
crossOrigin: 'anonymous',
})
```