title: javascript not loading in HTML file - nodejs + http
body: <p>Disclaimer: I am new to node.js so I assume there is a very basic answer to this question.</p>
  
  <p>I am using <strong>node.js</strong> on <strong>Windows</strong>, with <strong>http</strong> module to generate a static page with content generate from a js file.</p>
  
  <p><strong>Server file (server.js):</strong></p>
  
  <pre><code>var http = require('http');
  var fs = require('fs');
  
  fs.readFile('./index.html', function (err, html) {
      if (err) {
          throw err;
      }
      http.createServer(function(request, response) {
          response.writeHeader(200, {"Content-Type": "text/html"});
          response.write(html);
          response.end();
      }).listen(8080);
  });
  </code></pre>
  
  <p><strong>HTML file (index.html):</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;body&gt;
  
  &lt;div id="div1"&gt;
    &lt;p id="p1"&gt;This is a static paragraph.&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;p&gt;
    &lt;script type="text/javascript" src="start.js"&gt;&lt;/script&gt;
  &lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>JS file (start.js)</strong></p>
  
  <pre><code>var para = document.createElement("p");
  var node = document.createTextNode("This text is loaded from a js file.");
  para.appendChild(node);
  var element = document.getElementById("div1");
  element.appendChild(para);
  </code></pre>
  
  <p>When I load <strong>index.html</strong> directly, I get the following output:</p>
  
  <blockquote>
    <p>This is a static paragraph.</p>
    
    <p>This text is loaded from a js file.</p>
  </blockquote>
  
  <p>^^ this is my desired output.</p>
  
  <p><strong>Problem:</strong> However, when I use <strong>node.js</strong> and run <strong>server.js</strong>, the <strong>start.js</strong> content does not load. I get:</p>
  
  <blockquote>
    <p>This is a static paragraph.</p>
  </blockquote>
  
  <p>Any help would be appreciated.</p>
  
  <p>FYI, my folder structure</p>
  
  <pre><code>/
  - node_modules
  -- http
  -- fs
  - index.html
  - server.js
  - start.js
  </code></pre>