MCPcopy Index your code
hub / github.com/prettier/prettier / loadScript

Function loadScript

tests/config/browser-prettier/main.js:47–69  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

45};
46
47async function loadScript(url) {
48 const { document } = globalThis;
49 const { head } = document;
50 const script = Object.assign(document.createElement("script"), { src: url });
51
52 function on(event, callback) {
53 script.addEventListener(event, callback, { once: true, passive: true });
54 }
55
56 try {
57 await new Promise((resolve, reject) => {
58 on("load", resolve);
59
60 on("error", () => {
61 reject(new Error(`Failed to load script '${url}'.`));
62 });
63
64 head.appendChild(script);
65 });
66 } finally {
67 head.removeChild(script);
68 }
69}
70
71async function loadEsmPrettier() {
72 const [prettier, ...builtinPlugins] = await Promise.all(

Callers 1

loadUmdPrettierFunction · 0.85

Calls 3

onFunction · 0.85
rejectFunction · 0.85
removeChildMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…