From ab1270f3ba50e6f189822ff7dc486dfe1d91d058 Mon Sep 17 00:00:00 2001
From: Coleman Watts <coleman@civicrm.org>
Date: Sun, 20 Nov 2022 20:23:37 -0500
Subject: [PATCH] Menubar - Fix buggy, slow loader

---
 js/crm.menubar.js | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/js/crm.menubar.js b/js/crm.menubar.js
index 8360557f05da..9cfa4caeac4c 100644
--- a/js/crm.menubar.js
+++ b/js/crm.menubar.js
@@ -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')) {
+              observer.disconnect();
+              render(markup);
+            }
           }).observe(document, {childList: true, subtree: true});
         }
       }