How to add javascript to php page
<p>I see a lot of script adding Javascript to their webpages in different ways and am trying to figure out the correct way to do it.  For example, in the header of one of the php scripts I use it has this:</p>

<pre><code>&lt;script type="text/javascript" src="/javascriptfile.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;
var stuff = "file.php";                                         
var ip_add = '32.42.42.442';
&lt;/script&gt;
</code></pre>

<p>What I don't understand is why would you ever put the full javascript code in the header instead of just including it within a file.  For example, why not move the javascript mentioned about into it's own file and just just use this in your header:</p>

<pre><code>&lt;script type="text/javascript" src="/javascriptfile.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript" src="/javascriptfile2.js"&gt;&lt;/script&gt;
</code></pre>

<p>Are there certain times you should have the full javascript displayed in the page source instead of just linking to it in its own javascript file?</p>
