• Hey all. Going to ask this here too as no one has been able to respond in the themes section.

    I have what may be a no-brainer.

    By default, the way WP themes are built is that there are separate header.php, sidebar.php, comments.php, footer.php etc files in a theme. And for good reason for lots of people.

    However, does putting them all into one file and not loading them separately cause less stress on the webserver, as it them loads a single *.php file instead of 4-5 smaller every time a user visits a new page?

    Less queries, less stress?

    I may have totally misunderstood how this affects the under-the-hood of things, so wanted to asks someone who’s smarter at this than me.

    Thanks.

Viewing 1 replies (of 1 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    All includes are done on the server—essentially, PHP is copying and pasting the template files for you. It really doesn’t require much processing power. The reason that there’s a general recommendation to reduce the number of HTTP requests is because of the typical latency involved with each one. A remote call is generally much slower than a local one. Unless you’re storing your included template files on a remote server (which you probably aren’t) you will see virtually no benefit to inlining the code. If you want to reduce load, look into minifying and merging your JavaScript and CSS files.

Viewing 1 replies (of 1 total)
  • The topic ‘Single template file vs calling header.php/footer.php etc separately?’ is closed to new replies.