/load-script-promise

Enhancement version of dynamic script file loader for browser, with promise, restrict to load once and simple provider loader

Primary LanguageJavaScriptMIT LicenseMIT

load-script-promise

English | 简体中文

Enhancement version of dynamic script file loader for browser. New features are:

- Promise API return
- Restrict to load same src url only once regarding call load many times
- Simple provider loader, customizable provider load result detector, and simple infinite recursive provider dependency detection.

This repo is forked and modified from https://github.com/eldargab/load-script, thanks guys!

The structure and development mode of this repo is compatible with ES Module.

Npm package name is @horseluke/load-script-promise.

Installation

In Browser standalone mode (directly require in html file)

It is simple! Just include bundled file from dist folder (you can find this folder in repo), and then use loadScriptPromise Object.

loadScriptPromise Object is attached to window object in browser.

<!-- loadScriptPromise.js is for development -->
<script src="/dist/loadScriptPromise.min.js"></script>

More usages and examples can be found in folder /test/browser-test/cases.

You can open /test/browser-test/index.html to see how it works.

Doc "Browser API" has more details.

App development integration

First, use npm to install package.

npm i @horseluke/load-script-promise

Then go to doc "Lib API" to read more.

API

Please read docs in doc folder.

Test

This repo use mocha to run test.

Changelog

Please read docs CHANGELOG.md..

License

MIT