Dynamic loading (CDN / local script)
[![NPM Package][npm]][npm-url]
[![NPM downloads][npm-downloads]][npm-url]
!gzip size
!GitHub
English | 简体中文
#### Dynamic loading (CDN / local script)
The aim of the project is to create an easy to use, lightweight, cross-browser, general purpose loading script library.
> Check the code in the example if there is a problem in use.
>
> Try it in CodePen
You can use it at ./dist/*
``javascript`
`bash`
npm install dynamic-load-script --save
`bash`
yarn add dynamic-load-script --save
`javascript
import loadScript from 'dynamic-load-script';
loadScript('yourCDN')
.then((res) => {
// success...
})
.catch((err) => {
// fail...
});
`
Cloning the repo with all its history results in a ~2 MB download. If you don't need the whole history you can use the depth parameter to significantly reduce download size.
`bash``
git clone --depth=1 https://github.com/kangyana/dynamic-load-script.git
Copyright (c) 2022-present, kangyana
[npm]: https://img.shields.io/npm/v/dynamic-load-script
[npm-url]: https://www.npmjs.com/package/dynamic-load-script
[npm-downloads]: https://img.shields.io/npm/dm/dynamic-load-script