2

I want to use markdown in a website, I'm wondering about convert markdown to HTML client side or server side. I'll use https://github.com/evilstreak/markdown-js that has both client/server libraries. (node.js)

I never used markdown before and I'm wondering about the efficience of the two ways, the security too, because I don't want to have html tags from users (injections)

Do you have any advice or explanation about why do it client side or server side? Thanks.

4
  • Actually, I think that if I want to use markdown on the client, such as error handling, I must convert markdown to html in the client... So there should be no point to use it from server too. Am I right? Commented Jan 3, 2014 at 23:43
  • server side is the first choice unless you have a reason to render on client side. Commented Jan 3, 2014 at 23:53
  • Yes, it's what I thought first, but, if for example the user press a button and get a message, it this message is from a user variable treatment then I can't use markdown (Field password is required), you see? Commented Jan 3, 2014 at 23:58
  • 2
    Server side for the initial request - then client side for ajax updated content Commented Jan 4, 2014 at 0:34

1 Answer 1

5

If you're looking for efficiency, you should use the same module to render at both server-side and client-side.

Server side rendering is needed for initial request, and if your data is updated somehow by user, it needs to be re-rendered at the client-side.

Reasons:

  • client-side rendering is too slow for initial request because user needs to fetch all libraries first
  • server-side rendering is too slow for using after the page is loaded because it needs additional requests
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.