0

Continuing this question What is the best way to manage duplicate code in static HTML websites ...

I'm starting to create PHP variables for each chunk of duplicated HTML code. My website is divided into themes and each theme has its duplicated code. I have the option to:

  1. save all variables into a single PHP file, and then include it at the beginning of each HTML page (even if the page only uses one or two of those variables);
  2. create a PHP file for each "theme" and include at least two PHP files at each HTML (one with the common variables and other with the specific variables.

Which one is faster? Including several small PHP files increase the page's loading time? I think the "non-monolithic" version is easier to maintain... I just need to know if I'm sacrificing performance.

Community
  • 1
  • 1
dialex
  • 2,706
  • 8
  • 44
  • 74

2 Answers2

2

I just need to know if I'm sacrificing performance.

Except that you don't. This is premature optimization. Go for the one that maximizes maintainability and ease-of-programming.

Waleed Khan
  • 11,426
  • 6
  • 39
  • 70
0

I'd go with one file including all the necessary files or themes, that makes maintenance a lot simpler. If you mean faster to develop, that's also the one to go for.

I wouldn't worry about the performance. Your site is never going to be as slow including files you don't use as some of the frameworks out there.

thelastshadow
  • 3,406
  • 3
  • 33
  • 36