From e41c9bf172b5e9e2e5e5f21080f801b87d00e70b Mon Sep 17 00:00:00 2001 From: Ian <> Date: Fri, 8 Nov 2024 12:26:34 -0600 Subject: [PATCH] Simply load code --- scripts/delayed.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/scripts/delayed.js b/scripts/delayed.js index 6c9eaf8..992d2e0 100644 --- a/scripts/delayed.js +++ b/scripts/delayed.js @@ -8,21 +8,17 @@ sampleRUM('cwv'); async function loadBodyScript(src, attrs) { return new Promise((resolve, reject) => { - if (!document.querySelector(`body > script[src="${src}"]`)) { - const script = document.createElement('script'); - script.text = src; - if (attrs) { - // eslint-disable-next-line no-restricted-syntax, guard-for-in - for (const attr in attrs) { - script.setAttribute(attr, attrs[attr]); - } + const script = document.createElement('script'); + script.text = src; + if (attrs) { + // eslint-disable-next-line no-restricted-syntax, guard-for-in + for (const attr in attrs) { + script.setAttribute(attr, attrs[attr]); } - script.onload = resolve; - script.onerror = reject; - document.body.append(script); - } else { - resolve(); } + script.onload = resolve; + script.onerror = reject; + document.body.append(script); }); }