From 8f226c27d26ade044a26f9c834ffa2c5c8abb271 Mon Sep 17 00:00:00 2001 From: Alexandre Capt Date: Tue, 16 Jul 2024 14:34:36 +0200 Subject: [PATCH] feat: use rum js v2 (#371) --- scripts/delayed.js | 8 +------- scripts/scripts.js | 8 +++----- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/scripts/delayed.js b/scripts/delayed.js index 4f632597be..28fa26c8e2 100644 --- a/scripts/delayed.js +++ b/scripts/delayed.js @@ -1,7 +1 @@ -// eslint-disable-next-line import/no-cycle -import { sampleRUM } from './aem.js'; - -// Core Web Vitals RUM collection -sampleRUM('cwv'); - -// add more delayed functionality here +// add delayed functionality here diff --git a/scripts/scripts.js b/scripts/scripts.js index d47e412452..a76308bcc2 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -1,5 +1,4 @@ import { - sampleRUM, buildBlock, loadHeader, loadFooter, @@ -12,6 +11,7 @@ import { loadSection, loadSections, loadCSS, + sampleRUM, } from './aem.js'; /** @@ -82,6 +82,8 @@ async function loadEager(doc) { await loadSection(main.querySelector('.section'), waitForFirstImage); } + sampleRUM.enhance(); + try { /* if desktop (proxy for fast connection) or fonts already loaded, load fonts.css */ if (window.innerWidth >= 900 || sessionStorage.getItem('fonts-loaded')) { @@ -109,10 +111,6 @@ async function loadLazy(doc) { loadCSS(`${window.hlx.codeBasePath}/styles/lazy-styles.css`); loadFonts(); - - sampleRUM('lazy'); - sampleRUM.observe(main.querySelectorAll('div[data-block-name]')); - sampleRUM.observe(main.querySelectorAll('picture > img')); } /**