Skip to content

Commit

Permalink
feat: improve performance measuring
Browse files Browse the repository at this point in the history
  • Loading branch information
vtsaplin committed Dec 18, 2023
1 parent e688391 commit 44fccaf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions solutions/scripts/aem-perf-marks.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,26 @@ const config = {
attributeFilter: ['data-section-status', 'data-block-status'],
};

const ids = new Map();

const observer = new MutationObserver((mutations) => {

Check failure on line 39 in solutions/scripts/aem-perf-marks.js

View workflow job for this annotation

GitHub Actions / linting

Block must not be padded by blank lines

mutations.forEach((mutation) => {
const { target } = mutation;
// console.debug('MutationObserver', target); // eslint-disable-line no-console
console.debug('MutationObserver', target); // eslint-disable-line no-console
if (target.dataset.sectionStatus || target.dataset.blockStatus) {
const markName = Array.from(target.classList).join('_');
const status = target.dataset.sectionStatus || target.dataset.blockStatus;
if (status === 'loading') {
if (status === 'initialized') {
ids.set(target, markName);
target.dataset.perfMark = markName;
window.PerfMarks.create(markName, { section: target.id });
} else if (status === 'loaded') {
window.PerfMarks.measure(markName);
window.PerfMarks.measure(target.dataset.perfMark);
}
}
});

// if (element.dataset.sectionStatus) {
// const markName = element.classList.join('_');
// if (element.dataset.sectionStatus === 'initialized') {
Expand Down

0 comments on commit 44fccaf

Please sign in to comment.