0

I downloaded a theme which was set up with lots of "unnecessary" functions, but the core funtionality is good, rare, and very hard for me to re-create, so I want to stick with it. However, I have created a child theme to deal with these unnecessary thing, removing a lot and so on. I can now copy files from parent theme into my child theme folder and it will use my child theme files instead.

Now the child theme is getting very big and I will eventually have maybe 25-50 % of the parent theme files copied to the child theme structure. I assume this will be a lot of extra load on the site to have all these extra files? Or are the parent theme files "skipped" and "doesn't count" if I have them in my child theme?

Basically what I want to know is: Are there any performance issues (or other issues) that a large child theme will create?

2 Answers 2

2

I assume this will be a lot of extra load on the site to have all these extra files? Or are the parent theme files "skipped" and "doesn't count" if I have them in my child theme?

  • if the child theme file is slower than the parent theme file then yes
  • if the child theme file is faster than the parent theme file then no

Themes aren't slow because they're big or small, just as sites aren't slow because the number of plugins is high or low.

Sites are slow because they're trying to do either too many things, or expensive things. You could built a tiny theme that is very very slow, or a very large theme that is fast because everything it does is well built and simple.

What matters is the cost of the files that actually run.

Note that child themes can only replace theme templates that are loaded via locate_template and get_template_part. PHP files included via functions.php or with require/include can't be replaced this way and are still loaded and add additional weight.

If you end up copying all the templates from the parent theme to the child theme and modifying them, this on its own won't cause additional performance problems, it will likely run just as slow as the parent theme on its own plus whatever tweaks you made in the childs functions.php.

Wether your site slows down or speeds up is entirely dependent on the contents of those files. The number of files in total is not relevant.

The pedantic answer

To get a slowdown you would need to massively inflate the number of PHP files to the hundreds of MB, and load them all at once regardless of the page. This is because it takes time to load things off of storage and parse the PHP. Normally this is inconsequential but if you scale things up it eventually becomes noticeable. Getting to that point is quite difficult, especially on solid state storage.

You should expect to see some performance drops related to scanning for page templates in some circumstances, but I doubt that will affect frontend performance. The biggest issue to you as an admin is most likely to be the HTML of the dropdown that lists them.

Loading theme templates from a child theme via locate_template and get_template_part shouldn't see a slowdown as get_template part will at maximum check for the presence of 4 files when given 2 parameters.

The TLDR answer

This is not a question you need to ask, it isn't worth worrying about, and it's very deep in the realm of micro-optimisation. If you have any common debug plugin you can directly test and see for yourself.

1
  • Thank you very much for the answer Tom! I got the child theme set up for me so I have no idea how it is connected, the way I use it is if I need to edit a file from the parent theme, I copy that file into the child theme structure and edit it there and it all magically works (except in a few rare cases). Most of the work is optimizing what was written before, so then performance won't be an issue. Thanks again for the explaantion, I should really read up more on how child theme works :)
    – eligolf
    Commented Sep 23, 2022 at 3:28
0

Any template files in the child theme will override the same-named files in the parent theme. Quoting from the Template Hierarchy documentation:

When you are using a child theme, any file you add to your child theme will over-ride the same file in the parent theme. For example, both themes contain the same template category.php, then child theme's template is used.

If a child theme contains the specific template such as category-unicorns.php and the parent theme contains lower prioritized template such as category.php, then child theme's category-unicorns.php is used. Contrary, if a child theme contains general template only such as category.php and the parent theme contains the specific one such as category-unicorns.php, then parent's template category-unicorns.php is used.

References

The mere presence of the files in the theme won't increase the load on the server, as they won't be used unless needed.

3
  • 2
    This isn't entirely true. Only templates from the template hierarchy (and a few others like header.php or searchform.php) will automatically replace those from the parent theme. All other files, including functions files, scripts, and styles, can only be replaced by a child theme if the parent theme has loaded them in a child theme-friendly way. Commented Sep 22, 2022 at 16:53
  • That's a very good point, @Jacob Peattie. I assumed the question was about template files, but there are potentially many more assets in a theme than just template files.
    – Pat J
    Commented Sep 22, 2022 at 17:12
  • 1
    Thank you Pat, I will have a look at the links. I am sure they will make my understanding of child themes better :)
    – eligolf
    Commented Sep 23, 2022 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.