Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions express/code/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,26 +345,6 @@ function decorateHeroLCP(loadStyle, config, createTag) {
}
}

const listenAlloy = () => {
let resolver;
let loaded;
window.alloyLoader = new Promise((r) => {
resolver = r;
});
window.addEventListener('alloy_sendEvent', (e) => {
if (e.detail.type === 'pageView') {
// eslint-disable-next-line no-console
loaded = true;
resolver(e.detail.result);
}
}, { once: true });
setTimeout(() => {
if (!loaded) {
resolver();
}
}, 3000);
};

async function loadPage() {
if (window.isTestEnv) return;
const {
Expand Down Expand Up @@ -413,9 +393,6 @@ async function loadPage() {

loadLana({ clientId: 'express' });

// TODO this method should be removed about two weeks after going live
listenAlloy();

// prevent milo gnav from loading
const headerMeta = createTag('meta', { name: 'custom-header', content: 'on' });
document.head.append(headerMeta);
Expand All @@ -424,10 +401,6 @@ async function loadPage() {

buildAutoBlocks();
decorateHeroLCP(loadStyle, config, createTag, getMetadata);
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('martech') !== 'off' && getMetadata('martech') !== 'off') {
import('./instrument.js').then((mod) => { mod.default(); });
}

/* region based redirect to homepage */
import('./utils/location-utils.js').then(({ getCountry }) => getCountry()).then((country) => {
Expand All @@ -449,6 +422,11 @@ async function loadPage() {
const { fixIcons } = await import('./utils.js');
document.querySelectorAll('.section>.text').forEach((block) => fixIcons(block));

const urlParams = new URLSearchParams(window.location.search);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR gets instrument.js out of the LCP window which is the main win, but it still fires immediately after loadArea() rather than inside express-delayed.js where true Phase D work lands. Since you've already shown the DOM needs to be complete anyway and no fidelity is lost by deferring, would it make sense to move this entirely into express-delayed.js? Not a blocker — the current improvement is substantial — just curious if there's a reason to keep it in the middle.

if (urlParams.get('martech') !== 'off' && getMetadata('martech') !== 'off') {
import('./instrument.js').then((mod) => { mod.default(); });
}

import('./express-delayed.js').then((mod) => {
mod.default();
});
Expand Down
Loading