from-cdn
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

From CDN

npm

Promise based CDN loader for js/css

How use

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
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

Readme

Keywords

Package Sidebar

Install

npm i from-cdn

Weekly Downloads

485

Version

1.0.1

License

MIT

Unpacked Size

2.8 kB

Total Files

4

Last publish

Collaborators

  • mkozhukh