Search code examples
javascriptnode.jsserver-side

Node.js - Disabling Browser's Javascript


For instance, if a browser has javascript disabled does node.js still work or does it need a fallback?

I know this might be a stupid question, but i'm trying to prove to a friend that node.js works on the server-side and doesn't rely on the client side.


Solution

  • As pointed by @frédéric-hamidi run a node server and then curl it:

    nodejs

    var http = require('http');
    http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end('I don\'t need js on the browser!');
    }).listen(80);
    

    shell

    curl http://web-07081482-2b2c-4e1b-9b1c-9ab20dccb92c.runnable.com/
    

    You can show him this demo:

    http://runnable.com/VM9-XCkU5E06W8gl/nodejs-so-for-node-js-and-hello-world