( callback: Function, scriptUrl = defaultScriptUrl )
| 30 | }; |
| 31 | |
| 32 | export const loadScript = ( |
| 33 | callback: Function, |
| 34 | scriptUrl = defaultScriptUrl |
| 35 | ) => { |
| 36 | addCallback(callback); |
| 37 | |
| 38 | if (!isScriptInjected(scriptUrl)) { |
| 39 | const embedScript = document.createElement('script'); |
| 40 | embedScript.setAttribute('src', scriptUrl); |
| 41 | embedScript.onload = () => { |
| 42 | loaded = true; |
| 43 | runCallbacks(); |
| 44 | }; |
| 45 | document.head.appendChild(embedScript); |
| 46 | } else { |
| 47 | runCallbacks(); |
| 48 | } |
| 49 | }; |
no test coverage detected