I saw this code for button click for Jade
However, this is not really optimal, and using a script tag/external script makes your code more readable and easier to debug.
You cannot however use a
If you wish to separate concerns as much as possible, you can have your JS code in a separate .js file, but will still need to include that file in your rendered page.
Edit : An explanation on server/client interactions :
When you create a server in Node/Express, you are generating assets (html pages) from your templates. This generation, as well as what do to when a user reaches a route within your site, are handled by the server.
The server "serves" the source code page (the doc you see by clicking 'view source' to the client, which then interprets it.
TL;DR : the server only sends source code to the client, who's in charge of reading it and interpreting it.