From 930beed9003bd59c268fce4545ae6f0e62b1265f Mon Sep 17 00:00:00 2001 From: Chris Millar Date: Mon, 22 Jan 2024 16:31:27 -0700 Subject: [PATCH] Fix BACOM Homepage Marquee LCP When another block is placed above marquee (aside, etc.), that blocks image is selected as LCP when it should be marquee. This PR will prioritize marquee with a fallback to first document image if there is no marquee present. --- scripts/scripts.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/scripts.js b/scripts/scripts.js index d57758d..3621d81 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -148,9 +148,13 @@ const eagerLoad = (img) => { }; (async function loadLCPImage() { - const marquee = document.querySelector('.marquee.split'); + const marquee = document.querySelector('.marquee'); if (marquee) { - marquee.querySelectorAll('img').forEach(eagerLoad); + if (marquee.classList.contains('split')) { + marquee.querySelectorAll('img').forEach(eagerLoad); + } else { + eagerLoad(marquee.querySelector('img')); + } } else { eagerLoad(document.querySelector('img')); }