MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / load

Function load

packages/utils/src/script.ts:14–46  ·  view source on GitHub ↗
(url: string, scriptType?: string)

Source from the content-addressed store, hash-verified

12}
13
14export function load(url: string, scriptType?: string) {
15 const node = document.createElement('script');
16
17 // node.setAttribute('crossorigin', 'anonymous');
18
19 node.onload = onload;
20 node.onerror = onload;
21
22 const i = createDefer();
23
24 function onload(e: any) {
25 node.onload = null;
26 node.onerror = null;
27 if (e.type === 'load') {
28 i.resolve();
29 } else {
30 i.reject();
31 }
32 // document.head.removeChild(node);
33 // node = null;
34 }
35
36 node.src = url;
37
38 // `async=false` is required to make sure all js resources execute sequentially.
39 node.async = false;
40
41 scriptType && (node.type = scriptType);
42
43 document.head.appendChild(node);
44
45 return i.promise();
46}
47
48export function evaluateExpression(expr: string) {
49 // eslint-disable-next-line no-new-func

Callers 1

loadScriptMethod · 0.90

Calls 3

createDeferFunction · 0.90
promiseMethod · 0.80
createElementMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…