[wp-trac] [WordPress Trac] #62884: Total error otimization in nav-menu.js

WordPress Trac noreply at wordpress.org
Thu Jan 30 16:37:17 UTC 2025


#62884: Total error otimization in nav-menu.js
--------------------------+--------------------------------------
 Reporter:  iallixey      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Menus         |     Version:  6.7
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  javascript, performance
--------------------------+--------------------------------------
Changes (by sabernhardt):

 * keywords:  needs-refresh =>
 * focuses:   => javascript, performance
 * version:  6.7.1 => 6.7


Old description:

> Обнаружен баг, подробности тут
> https://ru.wordpress.org/support/topic/total-error-otimization-in-nav-
> menu-js/#post-12237511
>
> 800 элементов навигационного меню создают проблему зависания страницы и
> неудобство использования — 800 это правильное решение в нашем случае,
> новый Муниципальный сайт, это уже далеко не блог 🙂 В нашем случае острая
> необходимость в том чтобы меню было хорошее и работало правильно.
>
> Точно Вам говорю это не из-за Max Mega Menu, кто то из разработчиков
> упустил этот критически важный момент, в который упираются все серьёзные
> пользователи системы WordPress.
>
> Виновник испорченного кода в 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>
>
> в этот edit-menu-item-parent и edit-menu-item-order загружается вся
> структура существующего меню (повторение 800). Т.е. каждый пункт меню
> содержит в себе select с повторением 800 итого 800*800=640000 и все это
> для javascript вызывает нагрузку до 10 минут для отображения страницы… 🙁
>
> Я исправил эту ошибку — время формировнаия страницы редактирования меню
> от 9 до 20 секунд(!) Ура победа.
>
> В итоге перешел на новую версию 6.7.1 (она мне нравиться чистотой кода и
> скоростью), но сделал следующие исправления
>
> 30/01/2025
>
> Действие: Replace nav-menu object (all code files) in 6.7.1 from 6.6.2
> Результат: Исправлена ошибка зависания интерфейса редактирования
> элементов меню, которая проявляется с версии 6.7
>
> \iwa.toprayon.ru\mnt\toprayon.ru\wp-admin\includes
> class-walker-nav-menu-edit.php (файл вывода формы html шаблон)
>
>             <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>
> \iwa.toprayon.ru\mnt\toprayon.ru\wp-admin
> nav-menus.php
>
> \iwa.toprayon.ru\mnt\toprayon.ru\wp-admin\js
> nav-menu.js
> nav-menu.min.js
>
> \iwa.toprayon.ru\mnt\toprayon.ru\wp-includes
> nav-menu.php
> nav-menu-template.php
> class-walker-nav-menu.php
>
> ***************************************************************************
>
> ПРЕДЛАГАЮ СДЕЛАТЬ ВЕСЬ ИНТЕРФЕЙС РЕДАКТИРОВАНИЯ НАВИГАЦИОННОГО МЕНЮ НА
> AJAX событиях. Не удаляйте интерфейс редактирования навигационного меню —
> это правильный путь, порядок, ядро, удобство для разработчиков и конечных
> пользователей.
>
> С уважением, Алексей

New description:

 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, Алексей

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62884#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list