async-js-loader
Load a JavaScript library asynchronously and the same library is loaded only once.
Pre-requisites
The loaded JavaScript library uses var
to declare variables. In other words, a variable in the JavaScript library can be referenced using a property of the window
. It can only be used in Browser.
Install
npm i async-js-loader --save
Usage
You can use async-js-loader in JavaScript or TypeScript.
async/await + await-to-js
;;// If you use CommonJS (i.e NodeJS environment), it should be:// const loader = require('async-js-loader').default; async { const err AMap = await ; iferr console; return; console; // If there are other variables or functions in this JavaScript library, you can get them from "window". // console.log(window[variableName])}
Promise
; { ;}
License
MIT © Tintin
keywords
async script load promise