Skip to content

Commit

Permalink
Menubar - Fix buggy, slow loader
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Nov 21, 2022
1 parent a5de1b2 commit e8d8971
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions js/crm.menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@

// Wait for crm-container present on the page as it's faster than document.ready
function insert(markup) {
if ($('#crm-container').length) {
if (document.getElementById('crm-container')) {
render(markup);
} else {
new MutationObserver(function(mutations, observer) {
_.each(mutations, function(mutant) {
_.each(mutant.addedNodes, function(node) {
if ($(node).is('#crm-container')) {
render(markup);
observer.disconnect();
}
});
});
if (document.getElementById('crm-container')) {
render(markup);
observer.disconnect();
}
}).observe(document, {childList: true, subtree: true});
}
}
Expand Down

0 comments on commit e8d8971

Please sign in to comment.