MCPcopy
hub / github.com/unlayer/react-email-editor / loadScript

Function loadScript

src/loadScript.ts:32–49  ·  view source on GitHub ↗
(
  callback: Function,
  scriptUrl = defaultScriptUrl
)

Source from the content-addressed store, hash-verified

30};
31
32export 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};

Callers 1

EmailEditorInnerFunction · 0.90

Calls 3

addCallbackFunction · 0.85
isScriptInjectedFunction · 0.85
runCallbacksFunction · 0.85

Tested by

no test coverage detected