Where is better for render HTML when use NodeJS server?

If I want to serve web page that shows table of some contents, I have two option.

  1. When client request page, Node server just response with JSON data and script for draw HTML table. And draw table in client side with Javascript.
  2. When client request page, Node server render all of HTML code for table and response the code to client. So client will receive full HTML.

Which one is better way to render page? I have not enough skills about front-end so confuse what to do.

4 thoughts on “Where is better for render HTML when use NodeJS server?”

  1. I think the node server should render the HTML in case you need to add more content to the HTML. You might not be doing this, and I don’t want to assume you are, but if you are sending the code as a string and using eval() on it, I don’t recommend it. For more information, visit eval() is evil. You also can send a function to the client’s javascript, but, you could have to add more code later on, and also, malicious code could get hacked into the function resulting in high damage to your node server. It isn’t likely, but I think you should use your second option.


Leave a Comment