title: JQuery function stops working when moved to js file
body: <p>I've been developing my scripts in line and now want to start moving them to a js file. However, the first script I am moving will not work from the js file.</p>
  
  <pre><code>function listEvents(url, phash) {
      var hashlocation = phash.split('#')[1];
      if (hashlocation === undefined) {
          var page = '';
      } else {
          var page = hashlocation;
      }
      $('#events').empty().load(url + page);
  } 
  </code></pre>
  
  <p>Called from page like so;</p>
  
  <pre><code>$(window).load(function() {
      listEvents('&lt;? echo base_url(); ?&gt;ajax/events_ajax/',window.location.hash);
  });
  </code></pre>
  
  <p>The js file is loaded after the jquery library in the head before anyone asks. I have cleared my cache, put cloudflare into dev mode etc, and if I load the JS file in my browser I see my function. I'm not seeing any errors in the console. What am I missing?</p>