title: Is PHP include() or JS src to include file faster?
body: <p>Sometimes when I need to include the same group of elements in many web pages, I use PHP:</p>
  
  <pre><code>&lt;?php include "somefile.html" ?&gt;
  </code></pre>
  
  <p>When <code>somefile.html</code> is this:</p>
  
  <pre><code>&lt;h1&gt;TITLE&lt;/h1&gt;
  &lt;h2&gt;Subtitle&lt;/h2&gt;
  </code></pre>
  
  <p>And sometimes, when I'm too lazy to use PHP and turn on my local server, I use JS:</p>
  
  <pre><code>&lt;script src="somescript.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>When <code>somescript.js</code> is like this:</p>
  
  <pre><code>document.write(
      "&lt;h1&gt;TITLE&lt;/h1&gt;" +
      "&lt;h2&gt;Subtitle&lt;/h2&gt;"
  );
  </code></pre>
  
  <p>The second version is just a tiny bit more inconvenient, but I use both ways.</p>
  
  <p>However, I was wondering which way is customary and which way is faster.</p>
  
  <p>I know PHP is server-side and is pre-parsed into HTML first, but even though it loads before the JS does, I don't know if it's faster. Because JS is client-side, it is parsed by the browser and might be quicker than sending a request to the server (although I'm not totally sure - tell me if I'm making incorrect inferences).</p>
  
  <p>Feel free to tell me if I'm unclear and redirect me to another page that could help.</p>
  
  <p>Thanks.</p>