From d2a760bebe9199438108ab35044a649b9b050857 Mon Sep 17 00:00:00 2001 From: bosco-ensemble Date: Tue, 9 Apr 2024 10:26:09 -0700 Subject: [PATCH] TDW-2277 moved placeholder call to outside the function --- scripts/scripts.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/scripts.js b/scripts/scripts.js index 3c41c4d1..26baa0c6 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -701,6 +701,9 @@ async function waitForLCP() { }); } +// eslint-disable-next-line no-use-before-define +const placeholders = await fetchPlaceholders(); + /** * Decorates the page. */ @@ -710,7 +713,7 @@ async function loadPage(doc) { // eslint-disable-next-line no-use-before-define await loadLazy(doc); // eslint-disable-next-line no-use-before-define - await loadAds(); + await loadAds(placeholders); // eslint-disable-next-line no-use-before-define loadDelayed(doc); } @@ -1195,8 +1198,7 @@ async function OptanonWrapper() { await sendAnalyticsPageEvent(); } -async function loadAds() { - const placeholders = await fetchPlaceholders(); +async function loadAds(placeholders) { const isProd = window.location.hostname.endsWith(placeholders.hostname); if (!isProd === 'this') {