title: How can I include an external javascript file that contains coldfusion code?
body: <p>I have a few coldfusion files that use the same exact javascript code. I want to separate the javascript out into a .js file and include it in each of the files so that I don't have to repeat everything several times. So, I separated the javascript code into a file named "myPage.js", and in "myPage.cfm" I included a script tag -</p>
  
  <pre><code>&lt;script language="javascript" src="myPage.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>The problem is that there's some coldfusion code spread among the javascript that injects values using <code>&lt;cfoutput&gt;</code>s and such, and that is no longer being translated correctly, probably because it's trying to read it as pure javascript. Is there any way I can have an external js file but indicate that I want it to use coldfusion to interpret it as well?</p>
  
  <p>One workaround that I've found is to put the javascript into a coldfusion file instead of a javascript file, called "myPageJavascript.cfm", surround all the javascript code in a <code>&lt;script type="text/javascript"&gt;</code> tag, and then use a cfinclude to include that javascript in all the pages. This works fine, but it doesn't seem to me as intuitive as including a js file... What's the standard practice for situations like this? Is there any way to implement this as an external js file, or should I just stick to my coldfusion template file?</p>