title: How to call node js function from node js client side
body: <p>I am playing around with an html template and I have noticed that the developer doesn't use RequireJS or anything else to require and call different functions from other node files. Instead, they used this in the html file to initialise and call the function:</p>
  
  <pre><code>&lt;script src="../../assets.js/test.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
          $(document).ready(function(){
              test.initSomeFunction();
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>And I've got the below code in <code>assets/js/test.js</code> which defines <code>initSomeFunction</code> in javascript:</p>
  
  <pre><code>test = {
    initSomeFunction: function() {
       //Some code
    }
  
    initAnotherFunction: function() {
       //More code
    }
  }
  </code></pre>
  
  <p>(It would be helpful if someone can tell me what this method is called so that I can research it more.)</p>
  
  <p>My problem arises when I try to do the same thing in my node app in the home directory <code>/main.js</code>. The node app works fine on its own but when I add something like this:</p>
  
  <pre><code>test2 = {
    initMyFunction: function() {
      console.log("I finally decided to work! Good luck...");
    }
  }
  </code></pre>
  
  <p>and modify my html file like this:</p>
  
  
  
  <pre><code>&lt;script src="../../main.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
          $(document).ready(function(){
              test.initSomeFunction();
              test2.initMyFunction();
  
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>then it won't work. Can someone please point me to the right direction as I don't even know what to Google. I am trying to avoid using RequireJS or anything else as I am a total beginner and the method that the developer used sounds so simple and tempting.</p>