Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.
Merged
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
75 changes: 36 additions & 39 deletions js/editor-libs/perf.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
(function() {
'use strict';
'use strict';

/**
* Posts a name to set as a mark to Kuma for
* processing and beaconing to GA
* @param {Object} perf - The performance object sent to Kuma
*/
function postToKuma(perf) {
window.parent.postMessage(perf, 'https://developer.mozilla.org');
}
/**
* Posts a name to set as a mark to Kuma for
* processing and beaconing to GA
* @param {Object} perf - The performance object sent to Kuma
*/
function postToKuma(perf) {
window.parent.postMessage(perf, 'https://developer.mozilla.org');
}

postToKuma({ markName: 'interactive-editor-loading' });

/**
* Posts marks to set on the Kuma side, based on certain
* events during document loading. These will then be made
* available in performance tools, and beaconed to GA
*/
document.addEventListener('readystatechange', function(event) {
switch (event.target.readyState) {
case 'loading':
postToKuma({ markName: 'interactive-editor-loading' });
break;
case 'interactive':
postToKuma({
markName: 'interactive-editor-interactive',
measureName: 'ie-time-to-interactive',
startMark: 'interactive-editor-loading',
endMark: 'interactive-editor-interactive'
});
break;
case 'complete':
postToKuma({
markName: 'interactive-editor-complete',
measureName: 'ie-time-to-complete',
startMark: 'interactive-editor-loading',
endMark: 'interactive-editor-complete'
});
break;
}
});
})();
/**
* Posts marks to set on the Kuma side, based on certain
* events during document loading. These will then be made
* available in performance tools, and beaconed to GA
*/
document.addEventListener('readystatechange', function(event) {
switch (event.target.readyState) {
case 'interactive':
postToKuma({
markName: 'interactive-editor-interactive',
measureName: 'ie-time-to-interactive',
startMark: 'interactive-editor-loading',
endMark: 'interactive-editor-interactive'
});
break;
case 'complete':
postToKuma({
markName: 'interactive-editor-complete',
measureName: 'ie-time-to-complete',
startMark: 'interactive-editor-loading',
endMark: 'interactive-editor-complete'
});
break;
}
});