Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkozhukh/from-cdn
Simple JS/CSS loader
https://github.com/mkozhukh/from-cdn
Last synced: about 1 month ago
JSON representation
Simple JS/CSS loader
- Host: GitHub
- URL: https://github.com/mkozhukh/from-cdn
- Owner: mkozhukh
- Created: 2018-09-06T11:35:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-10T15:54:37.000Z (over 6 years ago)
- Last Synced: 2024-11-11T21:25:26.944Z (2 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
From CDN
=========[![npm](https://img.shields.io/npm/v/from-cdn.svg)](https://www.npmjs.com/package/from-cdn)
Promise based CDN loader for js/css
### How use
```js
import fromCDN from "from-cdn";fromCDN([
"//cdn.some.com/a/a.js",
"//cdn.some.com/a/b.js",
"//cdn.some.com/a/a.css",
]).then( _ => alert("All is ready"))```
Function receives array of file links and returns a promise.
Promise will be resolved when all files are loaded- Code will not wait for CSS loading end!
- Order of JS files are not guaranteed, if you need to load few files in order, use```js
fromCDN(["//cdn.som.com/a/a1.js"])
.then( _ => fromCDN(["//cdn.som.com/a/a2.js"]))
.then( _ => fromCDN(["//cdn.som.com/a/a3.js"]))
```### License
MIT