@shinin/load-script

Load script asynchronously.

Usage no npm install needed!

<script type="module">
  import shininLoadScript from 'https://cdn.skypack.dev/@shinin/load-script';
</script>

README

@shinin/load-script ยท GitHub license npm Build Status

@shinin/load-script is a simple async script loader for modern browsers.

3 seconds quick view

import loadScript from '@shinin/load-script'

export default async function loadSDK() {
  await loadScript('http://foo.bar/sdk.js')
  // Now, you can do what you want after SDK.js has loaded...
}

Installation

npm install @shinin/load-script --save

Also you can use @shinin/load-script as a <script> tag from a CDN.

<!-- Use promise-polyfill only if you want to support old browsers. -->
<!-- <script src="https://unpkg.com/promise-polyfill"></script> -->
<script src="https://unpkg.com/@shinin/load-script/dist/load-script.min.js"></script>

Browser Support

License

MIT