[wp-trac] [WordPress Trac] #56666: Bug/performance: No need to make repeat calls to `get_theme_file_path` in `register_block_style_handle`
WordPress Trac
noreply at wordpress.org
Tue Sep 27 12:07:39 UTC 2022
#56666: Bug/performance: No need to make repeat calls to `get_theme_file_path` in
`register_block_style_handle`
--------------------------+--------------------
Reporter: aristath | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.1
Component: General | Version: trunk
Severity: normal | Keywords:
Focuses: performance |
--------------------------+--------------------
The `register_block_style_handle` function runs ~200 times on each page
load.
Each time it runs, we call `get_theme_file_path` and then run it through
`wp_normalize_path`.
`get_theme_file_path` calls `get_stylesheet_directory`, which calls
`get_stylesheet`, which calls `get_option`, and there's a bunch of filters
that run on each iteration of that - without ever changing.
We can cache the value and avoid 200 calls on many functions and filters -
improving performance.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56666>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list