[wp-trac] [WordPress Trac] #59595: Improve performance of WP_Theme_JSON::compute_style_properties

WordPress Trac noreply at wordpress.org
Wed Apr 24 15:28:01 UTC 2024


#59595: Improve performance of WP_Theme_JSON::compute_style_properties
-----------------------------------------+--------------------------
 Reporter:  spacedmonkey                 |       Owner:  thekt12
     Type:  enhancement                  |      Status:  assigned
 Priority:  normal                       |   Milestone:  6.6
Component:  Editor                       |     Version:  5.8
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch changes-requested  |     Focuses:  performance
-----------------------------------------+--------------------------

Comment (by joemcgill):

 Following up after chatting with @thekt12 about the circular dependency
 issue noted [https://github.com/WordPress/wordpress-
 develop/pull/6392#discussion_r1572619712 in my PR review]. To avoid this,
 we could consider creating a new method on the `WP_Theme_JSON_Resolver`
 class that will get computed styles for the merged JSON object, though a
 better approach is likely to move caching of this data to the
 `wp_add_global_styles_for_blocks()` helper which ends up calling
 `WP_Theme_JSON::compute_style_properties()` via
 `WP_Theme_JSON::get_styles_for_block()` for each registered block.

 In doing so, we may need break up caching so that we are only caching
 computed style properties for core blocks, so we can invalidate when the
 WP version changes. Otherwise, we will need to invalidate this cache
 whenever the registered blocks have changed, which is challenging because
 we don't have a concept of block versions, so an update to an existing
 block could introduce changes in the styles that would need to be
 accounted for.

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


More information about the wp-trac mailing list