From 09fc85de109621ea252c38b8b7a42923935322d2 Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Thu, 2 Jan 2025 12:55:55 +0530 Subject: [PATCH 1/5] Favicon quick load --- libs/utils/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 76c870eb1e..118b46b634 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -764,7 +764,9 @@ function decorateDefaults(el) { }); } -function decorateHeader() { +async function decorateHeader() { + const { default: loadFavIcon } = await import('./favicon.js'); + loadFavIcon(createTag, getConfig(), getMetadata); const breadcrumbs = document.querySelector('.breadcrumbs'); breadcrumbs?.remove(); const header = document.querySelector('header'); @@ -1294,8 +1296,6 @@ async function documentPostSectionLoading(config) { addRichResults(richResults, { createTag, getMetadata }); } loadFooter(); - const { default: loadFavIcon } = await import('./favicon.js'); - loadFavIcon(createTag, getConfig(), getMetadata); if (config.experiment?.selectedVariant?.scripts?.length) { config.experiment.selectedVariant.scripts.forEach((script) => loadScript(script)); } From 0ec1d9dec3273a0316dddd0af4d7d99541f890e8 Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Thu, 2 Jan 2025 13:21:59 +0530 Subject: [PATCH 2/5] code optimization --- libs/utils/utils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 118b46b634..34b7e9dc01 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -765,8 +765,6 @@ function decorateDefaults(el) { } async function decorateHeader() { - const { default: loadFavIcon } = await import('./favicon.js'); - loadFavIcon(createTag, getConfig(), getMetadata); const breadcrumbs = document.querySelector('.breadcrumbs'); breadcrumbs?.remove(); const header = document.querySelector('header'); @@ -1274,6 +1272,10 @@ function decorateMeta() { } function decorateDocumentExtras() { + (async () => { + const { default: loadFavIcon } = await import('./favicon.js'); + loadFavIcon(createTag, getConfig(), getMetadata); + })(); decorateMeta(); decorateHeader(); } From 5906248b15069c8c029cbaa378aab089aba85b18 Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Thu, 2 Jan 2025 13:28:23 +0530 Subject: [PATCH 3/5] code optimization --- libs/utils/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 34b7e9dc01..1fa8adff4c 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -1272,12 +1272,12 @@ function decorateMeta() { } function decorateDocumentExtras() { + decorateMeta(); + decorateHeader(); (async () => { const { default: loadFavIcon } = await import('./favicon.js'); loadFavIcon(createTag, getConfig(), getMetadata); })(); - decorateMeta(); - decorateHeader(); } async function documentPostSectionLoading(config) { From 20650a53f60635a1709940e92092233032a94811 Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Thu, 2 Jan 2025 13:31:33 +0530 Subject: [PATCH 4/5] code optimization --- libs/utils/utils.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 1fa8adff4c..43fdcc8255 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -788,6 +788,8 @@ async function decorateHeader() { if (breadcrumbs) header.append(breadcrumbs); const promo = getMetadata('gnav-promo-source'); if (promo?.length) header.classList.add('has-promo'); + const { default: loadFavIcon } = await import('./favicon.js'); + loadFavIcon(createTag, getConfig(), getMetadata); } async function decorateIcons(area, config) { @@ -1274,10 +1276,6 @@ function decorateMeta() { function decorateDocumentExtras() { decorateMeta(); decorateHeader(); - (async () => { - const { default: loadFavIcon } = await import('./favicon.js'); - loadFavIcon(createTag, getConfig(), getMetadata); - })(); } async function documentPostSectionLoading(config) { From 134e8295f0b741971ba9efce62b5d80eecb0cf6f Mon Sep 17 00:00:00 2001 From: sharath kannan Date: Fri, 3 Jan 2025 17:57:41 +0530 Subject: [PATCH 5/5] favicon is loaded post LCP --- libs/utils/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 43fdcc8255..8211642afc 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -788,8 +788,6 @@ async function decorateHeader() { if (breadcrumbs) header.append(breadcrumbs); const promo = getMetadata('gnav-promo-source'); if (promo?.length) header.classList.add('has-promo'); - const { default: loadFavIcon } = await import('./favicon.js'); - loadFavIcon(createTag, getConfig(), getMetadata); } async function decorateIcons(area, config) { @@ -1140,6 +1138,8 @@ async function checkForPageMods() { } async function loadPostLCP(config) { + const { default: loadFavIcon } = await import('./favicon.js'); + loadFavIcon(createTag, getConfig(), getMetadata); await decoratePlaceholders(document.body.querySelector('header'), config); const sk = document.querySelector('aem-sidekick, helix-sidekick'); if (sk) import('./sidekick-decorate.js').then((mod) => { mod.default(sk); });