Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#16799 closed enhancement (fixed)

Bloated Custom Menus

Reported by: kingkool68's profile kingkool68 Owned by:
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.1
Component: Menus Keywords: has-patch
Focuses: Cc:


tl;dr = WordPress should limit the size of auto generated descriptions for menus. Ideally there should be no menu item descriptions.

I'm working on a project that uses a lot of custom menus. So many custom menus in fact that editing them nearly brings my server to it's knees. (10 menus x 70 items each maximum 2 levels deep)

The biggest problem I found is WordPress loads a description with each menu item. I had to turn off JavaScript to even see this field and that's when I saw large blobs of content are being loaded with each and every menu items.

When loading one menu Firebug clocked the HTML page weighing in at 2.3MB. I went to my database and ran the following SQL to remove the offending blurbs of bloated text...

UPDATE posts SET post_content = WHERE post_type LIKE 'nav_menu_item';

This reduced the page weight by half to 1.1MB. The menu still took a bit to load but now I could save it back to the database successfully.

Other work arounds to make custom menus usable included raising the max execution time for PHP on my server and increasing the $_POST and $_GET size limit.

Custom menus need to go on diet.

Attachments (5)

use-excerpts-in-menu-textarea.diff (1.2 KB) - added by filosofo 13 years ago.
16799.empty-title-description.diff (702 bytes) - added by duck_ 13 years ago.
16799.trim-descriptions.diff (1.2 KB) - added by duck_ 13 years ago.
16799.trim-filter.diff (1.7 KB) - added by duck_ 13 years ago.
Alternatively, wp_trim_words() on nav_menu_description filter
16799.remove-inputs.diff (3.6 KB) - added by duck_ 13 years ago.
Remove more inputs from Walker_Nav_Menu_Checklist

Download all attachments as: .zip

Change History (17)

#2 @jane
13 years ago

  • Component changed from General to Menus
  • Type changed from defect (bug) to enhancement
  • Version set to 3.1

I tend to agree, as far as pages go. I just made a custom menu, and it put the entire page content into the description field, which is insane. I can see auto-populating a description for things that have a Description field already (like Categories), but putting the full page into description is overkill.

#3 @nacin
13 years ago

We should shift it to excerpts, if not just blank. I figured that's what it already was.

#4 @filosofo
13 years ago

  • Keywords has-patch added

Patch assumes #16372 committed, as we need that to generate the excerpt.

#5 @nacin
13 years ago

  • Milestone changed from Awaiting Review to 3.3

#6 @scribu
13 years ago

  • Cc scribu added

#7 follow-up: @duck_
13 years ago

In [18733]:

Make new nav menu items have a blank description and attr_title. See #16799.

#8 in reply to: ↑ 7 @duck_
13 years ago

Replying to duck_:

In [18733]:

Make new nav menu items have a blank description and attr_title. See #16799.

Setting description and attr_title to blank for all new nav menu items per IRC discussion with rboren.

Further work:

  • Dropping more inputs from Walker_Nav_Menu_Checklist, e.g. attr_title (this has a typo in the name attribute anyway), xfn, target
  • Trimming the description (and title's) of old nav menu items. See filosofo's patch.

#9 @kawauso
13 years ago

  • Cc kawauso added

#10 @duck_
13 years ago

In [18734]:

Rescue those who created menu items before r18733. Trim menu item descriptions. See #16799.

13 years ago

Alternatively, wp_trim_words() on nav_menu_description filter

13 years ago

Remove more inputs from Walker_Nav_Menu_Checklist

#11 @duck_
13 years ago

16799.remove-inputs.diff pulls out some more hidden inputs from WP_Nav_Menu_Checklist. menu-item-object and menu-item-type are required for the code in admin-ajax.php to retrieve the objects to convert to menu items. menu-item-url is necessary for no-JS as it's used in wp_save_nav_menu_items().

Savings on a site with 200 posts, 51 pages, 20 cats and tags. nav-menus.php with no menus drops from 259KB to 144KB.

See #14415 ("but there's [no] reason we couldn't omit a couple of others"), [16096]

#12 @jane
13 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Main thrust of this ticket was removing descriptions, which is done, so am closing ticket as fixed. To propose/submit additional menu enhancements, please open new. specific tickets, one idea per ticket so that they can be tracked more easily.

Note: See TracTickets for help on using tickets.