#56666 closed defect (bug) (fixed)
Bug/performance: No need to make repeat calls to `get_theme_file_path` in `register_block_style_handle`
| Reported by: | aristath | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.1 |
| Component: | General | Version: | 6.1 |
| Severity: | normal | Keywords: | has-patch add-to-field-guide |
| Cc: | Focuses: | performance |
Description
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.
Change History (5)
This ticket was mentioned in PR #3341 on WordPress/wordpress-develop by aristath.
4 years ago
#1
- Keywords has-patch added
mukeshpanchal27 commented on PR #3341:
4 years ago
#2
@aristath Can we add this new cache related code after the if statement line no. 222? Because we required it there, not prior?
SergeyBiryukov commented on PR #3341:
4 years ago
#4
Thanks for the PR! Merged in r54327.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Trac ticket: https://core.trac.wordpress.org/ticket/56666