[wp-trac] [WordPress Trac] #51691: Call get_template_directory() once instead of multiple times for loading theme's files (performance boost)
WordPress Trac
noreply at wordpress.org
Mon Nov 2 03:20:44 UTC 2020
#51691: Call get_template_directory() once instead of multiple times for loading
theme's files (performance boost)
----------------------------+------------------------------
Reporter: hellofromTonya | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Bundled Theme | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses: performance
----------------------------+------------------------------
Comment (by SergeyBiryukov):
Replying to [ticket:51691 hellofromTonya]:
> ''Each time'' `get_template_directory()` runs, ''multiple'' other
functions and filters also run including these 5 hooks:
>
> - `pre_option_template`
> - `alloptions`
> - `option_template`
> - `theme_root`
> - `template_directory`
If any of these have specific performance concerns, I think a better way
forward for this ticket might be to explore adding some object caching or
static variables to minimize the overhead.
I think a theme should be able to call `get_template_directory()` multiple
times without a noticeable performance impact. So I would go with the
final option here:
> Another way:
> - Implement within Core
>
> The overall goal is to improve performance by reducing memory, CPU
cycles, and processing time.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51691#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list