diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-10 15:09:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-10 15:09:43 +0300 |
commit | 3e06afc4cd1b75b3e957e8debf5e4f1963ba18e0 (patch) | |
tree | 24da37ec94b577201657e21c4071eaabcd69c193 /app/assets/javascripts/performance_bar | |
parent | b2e3191074dc12ca0a29a8815db65da9275d7764 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/performance_bar')
-rw-r--r-- | app/assets/javascripts/performance_bar/index.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/assets/javascripts/performance_bar/index.js b/app/assets/javascripts/performance_bar/index.js index f29b5f42d8f..41dae10ebbd 100644 --- a/app/assets/javascripts/performance_bar/index.js +++ b/app/assets/javascripts/performance_bar/index.js @@ -123,11 +123,23 @@ const initPerformanceBar = el => { }); }; -document.addEventListener('DOMContentLoaded', () => { +let loadedPeekBar = false; +function loadBar() { const jsPeek = document.querySelector('#js-peek'); - if (jsPeek) { + if (!loadedPeekBar && jsPeek) { + loadedPeekBar = true; 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(); |