1

I created a webpage with html5/css and some javascript (jquery). Now i want to extend my page with some functionality (server side ways), but i dont want to use php. I searched for an alternative and found node.js, now i want to use it.

But honestly i dont unterstand how it works (in the context to extend my page, i do unterstand javascript). I began to read some tutorials, but they always start explaining stuff to build a website with node.js (from scratch), but i want to extend my already existing site with some functionality (forum, maybe cms) and dont want to build the page from scratch.

I ordered some days ago a book about node.js, but i'm curious, sry for that.

I'd very appreciate if you could help me. I'm also grateful for some links, etc. :)

Cheers, Sven

Alah Din
  • 23
  • 1
  • 4
  • What do you already have as your existing site? How is it hosted? – crackmigg Mar 06 '16 at 18:35
  • i didnt uploaded it yet, because its not complete. Atm. it runs on my local machine. I use bootstrap, html5, css and some javascript (jQuery). – Alah Din Mar 06 '16 at 18:39
  • The thing is that you can not host a small site with some dynamic content as easy and cheap with node.js as with PHP. With node.js you have to write your own listener to a port. That's why the tutorials build the sites from scratch. Just checkout how to host PHP/node.js. And there is a question about when to use node.js: http://stackoverflow.com/questions/5062614/how-do-i-decide-when-to-use-node-js?rq=1 As though I am a big fan of node.js and use it daily it might not be the best choice for your case. – crackmigg Mar 06 '16 at 18:45
  • Ah ok. There is an easy explenation why i want to use node.js. Its modern and fast. Php is in contradiction slow and old. :D You are completely right, Php suits more in my case than node.js, but i want also the option to scale my code when my site goes very well and has very much user hits per day. I don't want to rewrite then the whole page (from php to node.js for example). I'm also interested in new technology, i have the feeling that php disappears in 5-10 years. I dont know what to do when im honest. – Alah Din Mar 06 '16 at 18:57
  • Then you should go that way and use e.g. express.js and setup a server from scratch. Maybe also meteor is for you. There are many options. But you have to do a little more than just hook some tags into your HTML. There are some template engines like jade or ejs, you can read up on them e.g. here: https://strongloop.com/strongblog/compare-javascript-templates-jade-mustache-dust/ – crackmigg Mar 06 '16 at 19:04

1 Answers1

0

The thing about node.js is it's used to write servers. What this means is that you have to handle receiving requests from browsers and sending responses back for every. single. page. This is why tutorials on node.js start from scratch, because you can't just add node.js on to a webpage (like you can with php). node.js is like the backbone of your website, not some server side augmentation.

Elliot E
  • 452
  • 3
  • 14
  • do you think that i should forget about node.js and better use php in my case? – Alah Din Mar 06 '16 at 18:58
  • It's hard to say without knowing how big your website is, and I love node js, but I think php is not as bad as it may seem for adding some server side functionality to a website. But if your website isn't too complex migrating it to a node js server may not be that hard. edit: also I recommend creating a small website/server from scratch with node so you can understand how it works a bit before you start using it with your existing website. – Elliot E Mar 06 '16 at 19:01
  • My site is not that big, i give it a try. ;) Thanks a lot! – Alah Din Mar 06 '16 at 19:08