Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nemtsov/tiny-script-loader
Tiny script loader
https://github.com/nemtsov/tiny-script-loader
script-loader
Last synced: about 1 month ago
JSON representation
Tiny script loader
- Host: GitHub
- URL: https://github.com/nemtsov/tiny-script-loader
- Owner: nemtsov
- License: apache-2.0
- Created: 2016-08-11T22:30:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-24T17:00:06.000Z (6 months ago)
- Last Synced: 2024-11-14T22:09:23.747Z (about 2 months ago)
- Topics: script-loader
- Language: JavaScript
- Homepage:
- Size: 91.8 KB
- Stars: 8
- Watchers: 25
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tiny Script Loader [![Build Status](https://img.shields.io/travis/behance/tiny-script-loader.svg)](http://travis-ci.org/behance/tiny-script-loader) [![NPM version](https://img.shields.io/npm/v/tiny-script-loader.svg)](https://www.npmjs.com/package/tiny-script-loader) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
The purpose of this library is to be the smallest callback & Promise -based script loader.
## Usage
**Callback**
```js
var loadScript = require('tiny-script-loader/loadScript')loadScript('https://example.com/script.js', function () {
console.log('loaded')
})
```**Promise**
```js
var loadScript = require('tiny-script-loader/loadScriptPromised')loadScript('https://example.com/script.js')
.then(function () {
console.log('loaded')
})
```**Additional attributes**
```js
var loadScript = require('tiny-script-loader/loadScript')
var loadScriptPromised = require('tiny-script-loader/loadScriptPromised')loadScript('https://example.com/script.js', callbackFn, { crossOrigin: true })
loadScriptPromised('https://example.com/script.js', { type: 'javascript' })
.then(fn)
```
## License[Apache-2.0](/LICENSE)