News for hackers. Stuff that matters.
Re:Ask HN: Include JavaScript via PHP or HTML? by alttab on Wednesday March 10, 2010 @11:33PM (#1182979)
Actually, require_once is strictly server-side.

It will determine if the file has been included at anytime during that process and only include it if it wasn't previously there. This is a little slower than a direct include() because of the table look up first.

This could be causing it to render slow if you use 'require_once' a lot for the processing of your page. In your example, the lookups could cause your page to load slower. Note that if you type in your javascript via HTML no other processing is done as its treated as part of a text block.

Now with some context, to speed up the load of the page you should use include() instead of require_once. You must insure that this has only happened once per file during the processing of the request, or it will include that code again. This could cause a class redefinition error or bootstrap code to be run more than once.

If keeping track of that stuff gets tricky - its a sign that your PHP program is not structured enough to determine request-flow. Look into interfacing through a dispatcher and brush up on MVC best-practices.

I hope I was of help :)

Edit: After re-reading the question I realized I was answering the wrong question but this is probably a good tidbit about PHP so I'll elect to leave it. The other responders are right on in this case.

Re:Ask HN: Include JavaScript via PHP or HTML? by clusterfu_k on Wednesday March 10, 2010 @11:49PM (#1183007)
it wasnt really answering my question but this is definitely information that will help me improve the efficiency of my coding. thanks!