Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jade and client side javascript

I just started learning Express for nodejs using jade as a rendering engine, i have views and routes

Here are my views

layout.jade

  doctype html
    html
      head
        title= title
        link(rel='stylesheet', href='/stylesheets/style.css')
        link(href='/themes/bootstrap.min.css', rel='stylesheet')
        script(src='/javascripts/mygridwidjet.js', type='text/javascript')
      body
    block content

index.jade

extends layout

    block content
      h1= title
      p Welcome to #{title}
          .content-container-fluid
          .row
              .cols-sample-area
                  #Grid

and here are my routes

index.js

exports.index = function(req, res){
  res.render('index', { title: 'Football Archive' });
};

and i wrote my client side javascript which interacts with the #Grid

now i am really confused about where to put the client side javascript.

ps: i am a total noob, sorry if this question is so stupid.

like image 869
user1492051 Avatar asked Jun 06 '26 17:06

user1492051


1 Answers

You must put it in the folder public/ (create it if it does not exists)

myapp
 |
 |-node_modules/
 |   |-express/
 |   |-socket.io/
 |
 |-public/
 |   |-javascripts/
 |   |    |-mygridwidjet.js
 |   |-...
 | 
 |-server.js

Here is a more complex example (my app) : https://github.com/CraftYourModCorporation/RedstoneHub

like image 91
Vinz243 Avatar answered Jun 10 '26 11:06

Vinz243



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!