1.0.4 • Published 5 years ago
react-inject-script
Licence
MIT
Version
1.0.4
Deps
0
Size
3 kB
Vulns
0
Weekly
0
react-inject-script
Dynamically inject <script> to your react app html file. Benefit, we can load desired library on demand instead of load everything on start up.
Installation
yarn add react-inject-script
Usage
import injectScript from 'react-inject-script';
.....
injectScript('any-unique-name', 'https://link.to.file/min.js').then(() => {
setTimeout(() => console.log('Successfully loaded'), 1000);
})
.catch(e => {
console.log(`Failed to load: ${e}`);
});
description
'any-unique-name' should be unique per project. this to prevent from the