

Ask HN: Include JavaScript via PHP or HTML? - clusterfu_k

So in my regular website building duties I have noticed that including the text of my javascript file renders the page faster than if the javascript file was merely include via html.<p>(In PHP)<p>&#60;script type="text/javascript" src="stuff.js"&#62;&#60;/script&#62;<p>v.s.<p>&#60;script type="text/javascript"&#62;&#60;?php require_once("stuff.js");?&#62;&#60;/script&#62;<p>Is there any downside to me including the file via php?
======
there
the only downside would be if you are reusing the same javascript code on
another page, this would cause the browser to download it again each time. if
it's in a separate js file, the browser will (probably) cache it and make for
a shorter download of each subsequent page.

