Dynamically inject `<script>` to your react app html file. Benefit, we can load desired library on demand instead of load everything on start up.
npm install react-inject-scriptDynamically inject to your react app html file. Benefit, we can load desired library on demand instead of load everything on start up.
yarn add react-inject-script
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});
});
``'any-unique-name' should be unique per project. this to prevent from the