Using JavaScript Code Instead Of Referencing A File?
<p><strong>EDIT:</strong> Sorry, I should have been more clear. My webpage needs to be XHTML compliant.</p>

<p>I use a hosted blogging platform, and there's no way for me to host a JavaScript file on it. We normally reference JavaScript file on a web page like this:</p>

<pre><code>&lt;script type='text/javascript' src='http://example.com/js/mycode.js'&gt;&lt;/script&gt;
</code></pre>

<p>The question is, can I directly reference code in the web page, instead of the file? If so, how do I do that?</p>

<ol>
<li><p>Just paste the JavaScript code in the file between <code>&lt;script&gt;</code> tags?</p>

<pre><code>&lt;script type='text/javascript'&gt;
PASTE THE CODE FROM THE JS FILE HERE
&lt;/script&gt;
</code></pre></li>
<li><p>OR like this?</p>

<pre><code>&lt;script type='text/javascript'&gt;
//&lt;![CDATA[
PASTE THE CODE FROM THE JS FILE HERE
//]]&gt;
&lt;/script&gt;
</code></pre></li>
</ol>

<p>Which of the above two methods is correct? If not, is there a better way to do it?</p>

<hr>

<p>Also, can a text (.txt) file be referenced inside a script tag, like this?</p>

<pre><code>&lt;script type='text/javascript' src='http://example.com/js/mycode.txt'&gt;&lt;/script&gt;
</code></pre>

<p>or will there be any issues if I do it like this?</p>

<p>Looking for a knowledgeable answer.</p>
