Need advice on working on large javascript files
<p>I have about 2000 lines of javascript code for my application. A lot of this is user interaction / jQuery. Don't worry, it all works fine :)</p>

<p>But it's getting dificult to keep track of the code base. So I have split up the file into five files.</p>

<p>I thought that if I load all files, they all reside in memory and the can communicate with each other. but it does not look like it. Because, in file A, I have <code>var currentPage = getURLvar('slpage');</code> and in file B I have <code>if ( currentPage == 'someName')</code>.</p>

<p>But file B does not recognize the variable currentPage.</p>

<p>Also I have som general scripts in file C which file A nd B can use. But I guess that's not possible to cal leither?</p>

<p>Any advice is much appreciated.</p>

<p><strong>UPDATE</strong> <br /></p>

<p>My javascript start s like this:</p>

<pre><code>// FILE A
jQuery(document).ready(function() {

  var currentPage = getURLvar('slpage');

  if ( (currentPage == 'Aa') || (currentPage == 'Bb') ) { 
    init_AA();
  } 
  else if ( (currentPage == 'Cc') || (currentPage == 'Dd') ) {
    init_BB();    
  } else if ( (currentPage == 'Ee') || (currentPage == 'Ff') ) {
    init_CC();    
  }
  (...)

// FILE B
  function init_AA()
  { 
    (...)
  }

  function getURLvar(name)
  {
     //Gets the URL and returns the value of specified paramter.
  }
</code></pre>
