Opened 8 weeks ago
Last modified 8 weeks ago
#62884 new defect (bug)
Total error otimization in nav-menu.js
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.7 |
Component: | Menus | Keywords: | |
Focuses: | javascript, performance | Cc: |
Description (last modified by )
A bug has been found, details here
https://ru.wordpress.org/support/topic/total-error-otimization-in-nav-menu-js/#post-12237511
800 navigation menu elements create the problem of page freezing and inconvenience of use - 800 is the right decision in our case, the new Municipal website is far from being a blog 🙂 In our case, there is an urgent need for the menu to be good and work correctly.
I can tell you for sure that this is not because of Max Mega Menu, one of the developers missed this critically important point, which all serious users of the WordPress system run into.
The culprit of the broken code in 6.7.1 … class-walker-nav-menu-edit.php (
<div class="field-move-combo description-group"> <p class="description description-wide"> <label for="edit-menu-item-parent-<?php echo $item_id; ?>"> <?php _e( 'Menu Parent' ); ?> </label> <select class="edit-menu-item-parent widefat" id="edit-menu-item-parent-<?php echo $item_id; ?>" name="menu-item-parent[<?php echo $item_id; ?>]"> </select> </p> <p class="description description-wide"> <label for="edit-menu-item-order-<?php echo $item_id; ?>"> <?php _e( 'Menu Order' ); ?> </label> <select class="edit-menu-item-order widefat" id="edit-menu-item-order-<?php echo $item_id; ?>" name="menu-item-order[<?php echo $item_id; ?>]"> </select> </p> </div>
the entire structure of the existing menu (repetition 800) is loaded into this edit-menu-item-parent and edit-menu-item-order. That is, each menu item contains a select with a repetition of 800, total 800*800=640000, and all this for javascript causes a load of up to 10 minutes to display the page… 🙁
I fixed this error - the time it takes to generate the menu editing page is from 9 to 20 seconds(!) Hurray, victory.
As a result, I switched to the new version 6.7.1 (I like it for its clean code and speed), but made the following corrections
30/01/2025
Action: Replace nav-menu object (all code files) in 6.7.1 from 6.6.2
Result: Fixed the error of freezing the interface of editing menu items, which appears since version 6.7
wp-admin\includes\class-walker-nav-menu-edit.php
(file output form html template)
<p class="field-link-target description" style="display:none"> <label for="edit-menu-item-target-<?php echo $item_id; ?>"> <input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $menu_item->target, '_blank' ); ?> /> <?php _e( 'Open link in a new tab' ); ?> </label> </p> <span style="display:none"> <button type="button" class="button-link menus-move menus-move-left" data-dir="left"></button> <button type="button" class="button-link menus-move menus-move-right" data-dir="right"></button> </span>
wp-admin\nav-menus.php
wp-admin\js\nav-menu.js
wp-admin\js\nav-menu.min.js
wp-includes\nav-menu.php
wp-includes\nav-menu-template.php
wp-includes\class-walker-nav-menu.php
I suggest to make the entire navigation menu editing interface on Ajax events. Do not remove the navigation menu editing interface - this is the right way, order, core, convenience for developers and end users.
Best regards, Алексей