Commit 31f8a7b8 authored by Marc Shaw's avatar Marc Shaw

Fix performance bar loading issue

Currently the performance bar isn’t working correctly because we wait
until the dom content loaded event. This is triggered after some
requests have already been sent so we are missing these requests.

Issue: gitlab.com/gitlab-org/gitlab/-/issues/287794
MR: gitlab.com/gitlab-org/gitlab/-/merge_requests/48797
parent 17039d83
...@@ -123,11 +123,23 @@ const initPerformanceBar = el => { ...@@ -123,11 +123,23 @@ const initPerformanceBar = el => {
}); });
}; };
document.addEventListener('DOMContentLoaded', () => { let loadedPeekBar = false;
function loadBar() {
const jsPeek = document.querySelector('#js-peek'); const jsPeek = document.querySelector('#js-peek');
if (jsPeek) { if (!loadedPeekBar && jsPeek) {
loadedPeekBar = true;
initPerformanceBar(jsPeek); initPerformanceBar(jsPeek);
} }
}
// If js-peek is not loaded when this script is executed, this call will do nothing
// If this is the case, then it will loadBar on DOMContentLoaded. We would prefer it
// to be initialized before the DOMContetLoaded event in order to pick up all the
// requests sent from the page.
loadBar();
document.addEventListener('DOMContentLoaded', () => {
loadBar();
}); });
initPerformanceBarLog(); initPerformanceBarLog();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment