Skip to content

Commit

Permalink
feat: use rum js v2 (adobe#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
kptdobe authored and ramboz committed Jul 23, 2024
1 parent 2629743 commit 85a639a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 1 addition & 7 deletions scripts/delayed.js
Original file line number Diff line number Diff line change
@@ -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
8 changes: 3 additions & 5 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
sampleRUM,
buildBlock,
loadHeader,
loadFooter,
Expand All @@ -12,6 +11,7 @@ import {
loadSection,
loadSections,
loadCSS,
sampleRUM,
} from './aem.js';

/**
Expand Down Expand Up @@ -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')) {
Expand Down Expand Up @@ -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'));
}

/**
Expand Down

0 comments on commit 85a639a

Please sign in to comment.