I've developed a lot of PHP code snippets for my website, and I'm not sure where would be the best place to put them in order to reduce site loading times.
If they go in functions.php or in a dedicated plugin, then by default they will be loaded into every page of the site -- not just the pages that need them. Does this have a meaningful impact on load time, or is it inconsequential if the functions are never actually called?
It seems like it would be one step better to use a conditional like if(is_page_template()) { include_once('this-function.php'); }
and only load the functions on the pages that actually use them.
I could also include an external php file from the code of the template file itself, or even include the functions directly in the template. Both seem sloppy -- but is it faster?
Is the best method to wrap everything in classes rather than using named functions?