Searching the Support Forum, I see a lot of other customers have had this same problem for over a year now but haven’t found a definitive solution yet.
My main site menu has 58 items. I am using XVersion: 6.4.6 and ProVersion: 2.5.5.
The Problem:
Using Google Chrome, nav-menus.php takes significantly longer to load, and mouse events on the page take several seconds to fire. This problem is consistently reproducible on multiple desktop computers. For machines more than a few years old, this page appears to hang indefinitely.
The following actions did not fix the problem:
- Increased PHP memory limit to 512 M as per this post.
- Disabled all plugins (Cornerstone was already disabled)
Observations and Investigation:
With X Pro Theme enabled, the nav-menus.php tab requires almost 700 MB, about 10x more than other pages in the WP control panel. Some examples:
Plugins: 51 MB
Pages: 63 MB
Manage Themes: 53 MB
When I changed the active theme to something other than X or Pro, the problem was immediately fixed. As soon as I changed my theme back to X (not even Pro) the problem reappeared.
I noticed that, curiously, when using Microsoft Edge the delays are approximately 1/3 to 1/2 as long, although still very cumbersome to use. This leads me to suspect a JavaScript bottleneck. Sure enough, Chrome’s Task Manager shows CPU over 100% for that tab when it loads or tries to respond to mouse events. Using Chrome’s Developer Tools Profiler on nav-menus.php, the page takes 45 seconds to fully load. 56% of this time (22.6 seconds) the browser spent in DOM GC, and 11% of the time (4.5 seconds) it was performing Major GC. Profiling a mouse click on a menu item’s dropdown to open it revealed about 36 seconds are spent processing the mouseUp Event in onloadwff.js (at or near LPSiteNotification.A(e)
function).
Digging deeper, I found x-menus.js (v 2.5.5), set some breakpoints on the pretty-formatted version and reloaded the page. The ('select[class*="anchor_graphic_menu_item_display"]').each(...)
and n.on("change", ...)
lines are being invoked for every menu item being loaded. It looks like this code is registering at least 8 new change handlers for each item (the select[class...]
returns an iterable of size 8), and each loop adds at least two new Function objects onto the memory heap. Maybe this is irrelevant, maybe not: I didn’t analyze the function closures to see how big they are.
I took a memory heap dump and can share that if it helps. I can also share the page load profile.
There’s clearly some JavaScript from the basic X Theme that hooks into nav-menus.php and is causing this issue. I really, really love the expressiveness and flexibility of this theme, but since I need to update my main menu on a regular basis I’m beginning to question whether it’s worth the pain. Any help is greatly appreciated.