@shinin/load-script
v1.0.4
Published
Load script asynchronously.
Downloads
6
Maintainers
Readme
@shinin/load-script ·
@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
- Chrome
- Firefox
- Safari 7.1+
- Safari 5.1+ (with promises-polyfill)
- IE 8+ (with promises-polyfill)