Well ... In the first case, it is different what happens in the browser of what happens on the server. So, Jade is an HTML rendering, so if you are in a browser. This is what ExpressJS shipping, that is, the rendering of Jade. If you want to call, your HTML-Javascript (Rendering of Jade) should show you where Javascript is located. For exmaple
in Server.js
// Get the Javascript in the browser app.use("/javascripts", express.static("./outJavascripts")); // Get the URL app.all("/", function(req, res){ // Render the Jade and Send for the client (Browser) req.render("myTemplate.jade"); });
In myTemplate.jade
script(src='/javascripts/test.js')
In "./outJavascripts/test.js"
function check_test(){ console.log("It working! :D"); return "It working!"; }
If you do this, you will understand that it is running, the file "./outJavascripts/test.js" in the browser. And the function "check_test" never runs on the server.
source share