title: Getting content of a script file using Javascript
body: <p>I have the following script element in my web page:</p>
  
  <pre><code>&lt;script src="default.js" type="text/javascript"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Using JavaScript, I want to be able to retrieve the content of the script file. I know I could use an ajax request to get the data but then I am getting something from the server that I already have locally. </p>
  
  <p>So what I would prefer to do is retrieve the content from the DOM (if that's possible) or something that has the same result.</p>
  
  <p>Cheers
  Anthony </p>
  
  <p>UPDATE </p>
  
  <p>I was trying to simplify the question, maybe a bad a idea, I thought this way would cause less questions.</p>
  
  <p>The real situation I have is as follows, I actually have </p>
  
  <pre><code>&lt;script type="text/html" class="jq-ItemTemplate_Approval"&gt;
     ...
     html template that is going to be consumed by jQuery and jTemplate
     ...
  &lt;/script&gt;
  </code></pre>
  
  <p>Now this works fine but it means each time the page loads I have to send down the template as part of the HTML of the main page. So my plan was to do the following:</p>
  
  <pre><code>&lt;script src="template.html" type="text/html"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>This would mean that the browser would cache the content of template.html and I would not have to send it down each time. But to do this I need to be able to get the content from the file.</p>
  
  <p>Also in this case, as far as I know, requesting the content via ajax isn't going to help all that much because it has to go back to the server to get the content anyway.</p>