Search code examples
phphtmlperformancepagespeed

Which is better for website performance. PHP MySQL Query or plain HTML?


In terms of speed, performance, or plainly which is better for a website?

Lets say an html select tag with a lot of option tags inside, like for example 100

Would it be better to simply encode them right away with plain html like so . .

<select>
  <option value="1">First Something</option>
  <option value="2">Another Something</option>
  .
  .
  .
  <option value="100">Last Something</option>
</select>

or would it be better to query the values from a db and use php to setup the tags?

And how about for just 10 option tags inside a select tag? PHP + MySQL or just plain HTML?


Solution

  • Without doubt PHP/MySQL would be slower.

    Because if it's in HTML it would just print them, if it's PHP it will do the querying then print the same, so Step 1 takes shorter than Step 2 + Step 1.

    PHP would be shorter in your point of view but for the visitor it's the same populated page.