I am trying to learn the theory of node.js but can't seem to figure out how node.js knows whether to pre process it on the server or send it to browser for execution.
How to Determine Server vs Client Code in Node.js
javascriptnode.js
Related Topic
- Node.js – How to Write Reusable Code in Node.js
- JavaScript Asynchronous Programming – How Callbacks Work
- Node.js – How to Serve Content Without a Framework or Library
- Javascript – Are (mostly) client-side JavaScript web apps slower or less efficient
- Use node.js as http server
- Node.js Asynchronous Programming – Making Server Logic Independent of Client Interaction
Best Answer
node example.js
runs the code server side.require('./example.js')
within the server-side JavaScript file also runs the code server side.Serving a static file ending with ".js" to a client will make it a client-side JavaScript.