title: Play Framework - Defining my Javascript file within a function
body: <p>I'm using the Play Framework and am trying to define a javascript file within  a function in another javascript file (the reason being that I don't want these functions to be usable outside of the container function).</p>
  
  <p>So I have two javascripts files, ./public/javascripts/main.js, ./public/javascript/custom.js.</p>
  
  <p>From my html pages (index.scala.html) I define this as follows:</p>
  
  <pre><code>  &lt;script src="@routes.Assets.at("javascripts/main.js")"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Using "@routes...." doesn't work in main.js, so I tried adding the following:</p>
  
  <pre><code>  $.getScript("public/javascripts/custom.js", function(){
         alert("Script loaded and executed.");
      });
  </code></pre>
  
  <p>I've tried a variety of paths but it always says it can't find it.</p>
  
  <p>Any idea how to do this in Play please? Looked through as much documentation as I can and nothing is there...</p>
  
  <p>Any help would be brilliant!</p>
  
  <p>Thank you.</p>
  
  <p>Kind Regards,</p>
  
  <p>Gary Shergill</p>