[wp-trac] [WordPress Trac] #58560: Performance issues with `wp_common_block_scripts_and_styles`

WordPress Trac noreply at wordpress.org
Tue Jun 27 11:26:30 UTC 2023


#58560: Performance issues with `wp_common_block_scripts_and_styles`
---------------------------------------------+---------------------------
 Reporter:  spacedmonkey                     |       Owner:  spacedmonkey
     Type:  enhancement                      |      Status:  closed
 Priority:  normal                           |   Milestone:  6.3
Component:  Script Loader                    |     Version:  5.0
 Severity:  normal                           |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  performance
---------------------------------------------+---------------------------
Changes (by spacedmonkey):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"56064" 56064]:
 {{{
 #!CommitTicketReference repository="" revision="56064"
 Script Loader: Fix performance issues in
 `wp_common_block_scripts_and_styles`.

 In [52069] the function `wp_common_block_scripts_and_styles` was changed
 load individual theme stylesheets, if the current theme supports block
 styles and loading separate core block assets. To do this, the function
 calls many expensive file operation functions, such as `glob`,
 `file_exists` and `file_get_contents`. This is wasteful, as these
 functions are loaded on every page request, even request that do not
 include blocks, like REST API calls. In [56044] all core block styles are
 registered in a single place. In `register_core_block_style_handles` calls
 `glob` to get all css styles in block directories. While registering style
 and editor styles, also register block theme styles, under a new style
 handle. Example `wp-block-avatar-theme`. If the current theme supports
 block styles, also request the block to enqueue the theme style on the
 front end. As these new stylesheets have a path attribute set, the
 function `wp_maybe_inline_styles` will automatically inline the styles for
 you.

 Props spacedmonkey, flixos90, oandregal, costdev, audrasjb, mukesh27.
 Fixes #58560.
 }}}

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


More information about the wp-trac mailing list