title: Shared JS (Coffee) in Rails
body: <p>If I want to share some JavaScript function between different files under <em>app/assets/javascript</em> what would be the best way to I organise the directory structure?</p>
  
  <p>Let's say I have <em>shared.js.coffee</em></p>
  
  <pre><code>sharedFunction = -&gt;
    'Hello '
  </code></pre>
  
  <p>Now, how can I use it in some other place? Like here, in <em>welcome.js.coffee</em></p>
  
  <pre><code>welcome = (name) -&gt;
    sharedFunction() + name
  </code></pre>
  
  <p>How can I make <em>shared.js.cofee</em> <strong>always be loaded first</strong>?</p>
  
  <p>I tried to put it in the very beginning of <em>application.js</em>, but it doesn't change anything. Seems <em>shared</em> file loading too long, and <em>welcome</em> manages to start executing and notice that sharedFunction is not defined.</p>