WAIT: Performance Issue: Menu Rendering in Bricks Significantly Slows Down Page Load

Hi,
I’m not entirely sure if this is a bug. While building several pages in Bricks, I noticed a significant slowdown when adding a menu to the header. I have an eCommerce site built with Bricks hosted on a VPS with 4vCPU AMD EPYC 7303, 16GB RAM, and 160GB NVMe SSD. According to Code Profiler, Bricks takes 2.4 seconds to initialize.

Removing the menu (wp_menu) speeds up the page by 0.6 seconds!

I installed New Relic and analyzed the page load process in detail. Here’s what I found:

Frontend::render_element is executed 428 times, and Element_Container::render is executed 290 times.

Timing Details from New Relic (note: New Relic slows down the site, so times are slightly higher):

Custom/get_header 3,19s

– Custom/wp_head 480ms
– Custom/do_action 2,71s

— Custom/Bricks\Element_Container::render 2,7s

---- Custom/Bricks\Element_Nav_Menu::render 2,65s

----- Custom/walk_nav_menu_tree 2,64s

----- Custom/Walker::display_element 1,66s

----- Custom/Bricks\Frontend::render_data 1,59s

------ Custom/Bricks\Element_Container::render 1,58s
------- Custom/Bricks\Frontend::render_element 314ms
------- Custom/Bricks\Frontend::render_element 517ms
------- Custom/Bricks\Frontend::render_element 454ms
------- Custom/Bricks\Frontend::render_element 280ms

----- Custom/Walker::display_element 0,428s
----- Custom/Walker::display_element 0,131s
----- Custom/Walker::display_element 0,065s
----- Custom/Walker::display_element 0,097s
----- Custom/Walker::display_element 0,259s

It seems that with menus, Custom/walk_nav_menu_tree is triggered. For each first-level menu item, it calls Custom/Bricks\Element_Container::render. Then, for second- and third-level menus and their child elements, it repeatedly executes:

  • Frontend::render_element
  • Element::init

This eventually reaches the link level, where it executes:

  • Element_Text_Link::render
  • Element::set_link_attributes
  • Element::maybe_set_aria_current
  • Helpers::maybe_set_aria_current_page
  • url_to_postid
  • _prime_post_caches
  • wp_get_object_terms
  • Several others.
1 Like

Hello @leszek.kotlicki,

thank you for your report. For us, to investigate we will need to login to the website and make sure that we are able to update theme files, so we can test a few tings. Please create a staging website for testing. Thanks!

Can you send temporary login credentials to your test/staging website and a link to this thread to help@bricksbuilder.io using the email address you used during the purchase, so we can take a look?

Thank you,
Matej

Just sent - thank you!