title: Javascript code in <script> element within VB Razor
body: <p>I'm trying to include some JS in a view within a Razor conditional, but it keeps trying to interpret my JS as VB:</p>
  
  <pre><code>@If includeMoreJs Then
      @&lt;script type="text/javascript" src="/some-js-file.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="/some-other-js-file.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          function someFunction(p) {
              if (p) foo();
              else bar();
          }
      &lt;/script&gt;
  End If
  </code></pre>
  
  <p>I've also tried this with the <code>&lt;text&gt;</code> psuedo element as described here: <a href="https://stackoverflow.com/questions/4599169/using-razor-within-javascript">Using Razor within JavaScript</a></p>
  
  <pre><code>@If includeMoreJs Then
      &lt;text&gt;
      &lt;script type="text/javascript" src="/some-js-file.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="/some-other-js-file.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          function someFunction(p) {
              if (p) foo();
              else bar();
          }
      &lt;/script&gt;
      &lt;/text&gt;
  End If
  </code></pre>
  
  <p>but still no luck... How can I get VB to leave my JS alone?</p>