Skip to content

Commit

Permalink
chore(perf): add labs block during eager phase to prevent CLS
Browse files Browse the repository at this point in the history
  • Loading branch information
rofe committed Nov 17, 2023
1 parent 646b0b4 commit ce8d3d0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,14 @@ async function loadEager(doc) {

await window.hlx.plugins.run('loadEager');

// labs banner
const labs = getMetadata('labs');
if (labs) {
const labsBanner = buildBlock('labs', labs);
const h1 = document.querySelector('h1');
h1.parentElement.insertBefore(labsBanner, h1);
}

const main = doc.querySelector('main');
if (main) {
decorateMain(main);
Expand Down Expand Up @@ -683,16 +691,6 @@ async function loadLazy(doc) {
decorateGuideTemplateCodeBlock();
}

// labs banner
const labs = getMetadata('labs');
if (labs) {
const labsBanner = buildBlock('labs', labs);
const h1 = document.querySelector('h1');
h1.parentElement.insertBefore(labsBanner, h1);
decorateBlock(labsBanner);
loadBlock(labsBanner);
}

window.hlx.plugins.run('loadLazy');

sampleRUM('lazy');
Expand Down

0 comments on commit ce8d3d0

Please sign in to comment.