title: Node.js with Express: Importing client-side javascript using script tags in Jade views?
body: <p>I've got a node.js express server running with the Jade template engine.</p>
  
  <p>I've got a layout jade file which imports the body of individual views like so:</p>
  
  <pre><code>!!!
  html
  
      head
          title= title || 'Title not set.'
  
      body
          #header
              h1 Header.
  
          #content!= body //- this renders the body of an individual view
  
          #footer
              p Footer.
  </code></pre>
  
  <p>For example, the following index page:</p>
  
  <pre><code>p Welcome to the front page.
  
  p This page serves as a now.js test.
  </code></pre>
  
  <p>This works fine. However, I now want to include two client-side javascript libraries specifically for this index page (and thus not very every page, which is why I cannot put it in the head of layout).</p>
  
  <p>This works:</p>
  
  <pre><code>//- import jquery
  script(type='text/javascript', src='./jquery-1.5.2.min.js');
  
  //- import now.js (hosts itself)
  script(type='text/javascript', src='/nowjs/now.js')
  
  //- import the chat client
  script(type='text/javascript', src='./indexChatClient.js')
  
  p Welcome to the front page.
  
  p This page serves as a now.js test.
  </code></pre>
  
  <p>However, this loads the scripts to the body of the complete page, which is not valid HTML, right?</p>
  
  <p>As far as I know, the scripts should be loaded into the head if I want to do it properly, but the head section is handled by the layout file.</p>
  
  <p>So, how would I properly include these client-side javascript libraries specifically for a certain view/page?</p>