Prerequisites
- [*] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- [*] The issue still exists against the latest stable version of Elementor.
Description
Pages with complex content can have a large performance impact due to unconditional use of dynamic tags and reprocessing dynamic tags CSS on every page load, even if the result is empty.
Steps to reproduce
The exact steps are unclear as this is showing up for a client site with complex page design and content. This has been found using xhprof/profiling and xdebug to trace through code paths.
What is seen to happen happens in combination with other plugins, but is in elementors core API's that they all rely on.
What was found specifically is the dynamic tags manager function after_enqueue_post_css gets called via elementor/css-file/post/enqueue for every element post/item processed on a page. This can include posts added in via widgets or nav menu items.
This alone isn't too bad, but after that content seems to get rebuilt in a virtual DOM again every time even when the resulting output is nothing to render for CSS.
\Elementor\Core\DynamicTags\Dynamic_CSS::get_meta does not cache the metadata in any means to prevent the excessive reprocessing of content potentially 20+ times.
Additionally, if a post/document entity has already had its content rendered for a request, it should be stored in an array cache like the document manager doers for building the "DOM" tree.
Isolating the problem
This was tested with a client site using profiling and determined to be due to the core API's causing it.
Environment
System Info
```
== Server Environment ==
Operating System: Linux
Software: nginx/1.15.10
MySQL version: mariadb.org binary distribution v5.7.25
PHP Version: 7.3.4
PHP Max Input Vars: 1000
PHP Max Post Size: 256M
GD Installed: Yes
ZIP Installed: Yes
Write Permissions: All right
Elementor Library: Connected
== WordPress Environment ==
Version: 5.1.1
WP Multisite: No
Max Upload Size: 256 MB
Memory limit: 999M
Permalink Structure: /blog/%postname%/
Language: en-US
Timezone: America/New_York
Debug Mode: Inactive
== Theme ==
Name: AOLRC Extended
Version: 1.0.0
Author: AOLRC
Child Theme: Yes
Parent Theme Name: Astra
Parent Theme Version: 1.6.8
Parent Theme Author: Brainstorm Force
== User ==
Role: administrator
WP Profile lang: en_US
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
== Active Plugins ==
301 Redirects
Version: 2.40
Author: WebFactory Ltd
Admin Slug Column
Version: 0.4.0
Author: Chuck Reynolds
Advanced Custom Fields PRO
Version: 5.7.13
Author: Elliot Condon
AJAX Thumbnail Rebuild
Version: 1.13
Author: junkcoder, ristoniinemets
All-in-One WP Migration
Version: 6.77
Author: ServMask
Astra Pro
Version: 1.6.13
Author: Brainstorm Force
Classic Editor
Version: 1.4
Author: WordPress Contributors
Custom Adobe Fonts (Typekit)
Version: 1.0.11
Author: Brainstorm Force
Custom Fonts
Version: 1.0.8
Author: Brainstorm Force
Disable Comments
Version: 1.9.0
Author: Samir Shah
Elementor
Version: 2.5.14
Author: Elementor.com
Elementor Pro
Version: 2.5.5
Author: Elementor.com
Favorite Event
Version: 1.0.0
Author:
Header and Footer Scripts
Version: 2.1.0
Author: Digital Liberation
Page Links To
Version: 3.0.1
Author: Mark Jaquith
Perfect Dashboard
Version: 1.23.0
Author: Perfect Dashboard
Post Duplicator
Version: 2.20
Author: Metaphor Creations
Redirection
Version: 4.2.3
Author: John Godley
Restrict Weak Password
Version: 0.0.1
Author: Moxie
Search & Filter Pro
Version: 2.4.6
Author: Code Amp
Super Socializer
Version: 7.12.24
Author: Team Heateor
Support Dashboard
Version: 3.1.6
Author:
SVG Support
Version: 2.3.15
Author: Benbodhi
Ultimate Addons for Elementor
Version: 1.11.0
Author: Brainstorm Force
User Registration Zap
Version: 1.0.0
Author:
Wisepops
Version: 1.2.1
Author: Wisepops
WordPress Backup & Security Plugin - BlogVault
Version: 1.88
Author: Backup by BlogVault
WP Crontrol
Version: 1.7.1
Author: John Blackbourn & crontributors
WP Missed Schedule
Version: 2014.1231.2017.5
Author: sLaNGjIs Team
WP Rocket
Version: 3.3.1.1
Author: WP Media
Yoast SEO
Version: 11.1
Author: Team Yoast
== Must-Use Plugins ==
Kinsta Must-use Plugins
Version: 2.3.1
Author: Kinsta Team
Support Dashboard Bootstrap
Version:
Author:
== Log ==
:
Log: showing 20 of 312019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_4_products Finished
2019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_0_sitemap Start
2019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_0_sitemap Finished
2019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_0_popup_border_radius Start
2019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_0_popup_border_radius Finished
2019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_4_form Start
2019-04-05 11:13:04 [info] Elementor Pro/Upgrades - _v_2_5_4_form Finished
2019-04-05 11:13:04 [info] Elementor Pro/Upgrades - _v_2_5_0_posts Start (2 of 4, 50%)
2019-04-05 11:13:04 [info] Elementor Pro/Upgrades - _v_2_5_4_posts Start (2 of 4, 50%)
2019-04-05 11:13:04 [info] Elementor Pro/Upgrades - _v_2_5_0_posts Start (3 of 4, 75%)
2019-04-05 11:13:05 [info] Elementor Pro/Upgrades - _v_2_5_4_posts Start (3 of 4, 75%)
2019-04-05 11:13:05 [info] Elementor Pro/Upgrades - _v_2_5_0_posts Start (4 of 4, 100%)
2019-04-05 11:13:05 [info] Elementor Pro/Upgrades - _v_2_5_0_posts Finished
2019-04-05 11:13:05 [info] Elementor Pro/Upgrades - _v_2_5_4_posts Start (4 of 4, 100%)
2019-04-05 11:13:05 [info] Elementor Pro/Upgrades - _v_2_5_4_posts Finished
Prerequisites
Description
Pages with complex content can have a large performance impact due to unconditional use of dynamic tags and reprocessing dynamic tags CSS on every page load, even if the result is empty.
Steps to reproduce
The exact steps are unclear as this is showing up for a client site with complex page design and content. This has been found using xhprof/profiling and xdebug to trace through code paths.
What is seen to happen happens in combination with other plugins, but is in elementors core API's that they all rely on.
What was found specifically is the dynamic tags manager function
after_enqueue_post_cssgets called viaelementor/css-file/post/enqueuefor every element post/item processed on a page. This can include posts added in via widgets or nav menu items.This alone isn't too bad, but after that content seems to get rebuilt in a virtual DOM again every time even when the resulting output is nothing to render for CSS.
\Elementor\Core\DynamicTags\Dynamic_CSS::get_metadoes not cache the metadata in any means to prevent the excessive reprocessing of content potentially 20+ times.Additionally, if a post/document entity has already had its content rendered for a request, it should be stored in an array cache like the document manager doers for building the "DOM" tree.
Isolating the problem
This was tested with a client site using profiling and determined to be due to the core API's causing it.
Environment
System Info
```== Server Environment ==
Operating System: Linux
Software: nginx/1.15.10
MySQL version: mariadb.org binary distribution v5.7.25
PHP Version: 7.3.4
PHP Max Input Vars: 1000
PHP Max Post Size: 256M
GD Installed: Yes
ZIP Installed: Yes
Write Permissions: All right
Elementor Library: Connected
== WordPress Environment ==
Version: 5.1.1
WP Multisite: No
Max Upload Size: 256 MB
Memory limit: 999M
Permalink Structure: /blog/%postname%/
Language: en-US
Timezone: America/New_York
Debug Mode: Inactive
== Theme ==
Name: AOLRC Extended
Version: 1.0.0
Author: AOLRC
Child Theme: Yes
Parent Theme Name: Astra
Parent Theme Version: 1.6.8
Parent Theme Author: Brainstorm Force
== User ==
Role: administrator
WP Profile lang: en_US
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
== Active Plugins ==
301 Redirects
Version: 2.40
Author: WebFactory Ltd
== Must-Use Plugins ==
Kinsta Must-use Plugins
Version: 2.3.1
Author: Kinsta Team
== Log ==
:
Log: showing 20 of 312019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_4_products Finished
2019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_0_sitemap Start
2019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_0_sitemap Finished
2019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_0_popup_border_radius Start
2019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_0_popup_border_radius Finished
2019-04-05 11:13:03 [info] Elementor Pro/Upgrades - _v_2_5_4_form Start
2019-04-05 11:13:04 [info] Elementor Pro/Upgrades - _v_2_5_4_form Finished
2019-04-05 11:13:04 [info] Elementor Pro/Upgrades - _v_2_5_0_posts Start (2 of 4, 50%)
2019-04-05 11:13:04 [info] Elementor Pro/Upgrades - _v_2_5_4_posts Start (2 of 4, 50%)
2019-04-05 11:13:04 [info] Elementor Pro/Upgrades - _v_2_5_0_posts Start (3 of 4, 75%)
2019-04-05 11:13:05 [info] Elementor Pro/Upgrades - _v_2_5_4_posts Start (3 of 4, 75%)
2019-04-05 11:13:05 [info] Elementor Pro/Upgrades - _v_2_5_0_posts Start (4 of 4, 100%)
2019-04-05 11:13:05 [info] Elementor Pro/Upgrades - _v_2_5_0_posts Finished
2019-04-05 11:13:05 [info] Elementor Pro/Upgrades - _v_2_5_4_posts Start (4 of 4, 100%)
2019-04-05 11:13:05 [info] Elementor Pro/Upgrades - _v_2_5_4_posts Finished