From e0b12f8e125a48e355123d672d421d81c1b58f7d Mon Sep 17 00:00:00 2001 From: Brandon Marshall Date: Mon, 12 Feb 2024 13:44:00 -0800 Subject: [PATCH 1/2] MWPW-135751 faas loading --- scripts/scripts.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/scripts.js b/scripts/scripts.js index 421452d..c703b3c 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -13,7 +13,7 @@ import { setLibs } from './utils.js'; const LIBS = '/libs'; -const STYLES = ['/styles/styles.css', '/styles/faas.css']; +const STYLES = ['/styles/styles.css']; const CONFIG = { imsClientId: 'bacom', local: { @@ -201,4 +201,10 @@ const miloLibs = setLibs(LIBS); const { default: registerAAUniversity } = await import('./aa-university.js'); window.addEventListener('mktoSubmit', registerAAUniversity); } + if (document.querySelector('.faas')) { + const link = document.createElement('link'); + link.setAttribute('rel', 'stylesheet'); + link.setAttribute('href', '/styles/faas.css'); + document.head.appendChild(link); + } }()); From 76b31d17ccbde1b67af4d959b613341145b3bd84 Mon Sep 17 00:00:00 2001 From: Brandon Marshall Date: Tue, 13 Feb 2024 12:26:40 -0800 Subject: [PATCH 2/2] PR Changes --- scripts/scripts.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/scripts.js b/scripts/scripts.js index c703b3c..18fd838 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -147,6 +147,13 @@ const eagerLoad = (img) => { img?.setAttribute('fetchpriority', 'high'); }; +const loadStyle = (path) => { + const link = document.createElement('link'); + link.setAttribute('rel', 'stylesheet'); + link.setAttribute('href', path); + document.head.appendChild(link); +}; + (async function loadLCPImage() { const marquee = document.querySelector('.marquee'); if (!marquee) { @@ -174,12 +181,7 @@ const miloLibs = setLibs(LIBS); if (STYLES) { paths.push(...(Array.isArray(STYLES) ? STYLES : [STYLES])); } - paths.forEach((path) => { - const link = document.createElement('link'); - link.setAttribute('rel', 'stylesheet'); - link.setAttribute('href', path); - document.head.appendChild(link); - }); + paths.forEach(loadStyle); }()); (async function loadPage() { @@ -202,9 +204,6 @@ const miloLibs = setLibs(LIBS); window.addEventListener('mktoSubmit', registerAAUniversity); } if (document.querySelector('.faas')) { - const link = document.createElement('link'); - link.setAttribute('rel', 'stylesheet'); - link.setAttribute('href', '/styles/faas.css'); - document.head.appendChild(link); + loadStyle('/styles/faas.css'); } }());