3

On this topic, it is said that SO uses :

On the server it is MarkdownSharp:
http://code.google.com/p/markdownsharp/

On the client it is PageDown:
http://code.google.com/p/pagedown/

So this tells us that when displaying a question/answer, StackOverflow's server delivers directly the answer as HTML (processed by MarkdownSharp for Markdown -> HTML).

Why doesn't the server deliver the answer in Markdown to the client and let the client render the page with Pagedown JS?

Then using MarkdownSharp would be unneeded, the server load would be lower, and the client load would not be important (converting an answer from Markup to HTML is really fast on client with Pagedown JS)?

Note: This is question is a Javascript-question but also a meta-StackOverflow question, that's why I didn't know exactly if I should post on meta.SO or SO.

2
  • 2
    Meta SO is fine for this question.
    – Makoto
    Mar 24, 2015 at 16:35
  • ... could you imagine the fun for those people who somehow get a blocked .js file because of the location it is hosted and the page rendering then? Also, there's a lot more to the page than just the markdown. And that assumes the same markdown dialect.
    – user289086
    Mar 24, 2015 at 16:47

1 Answer 1

8

My guess: Simplicity, reliability, and there is no saving to be had anyway.

  1. There are two situations in which the markdown source must be translated to HTML on the server under any circumstances:

    • The client has JavaScript disabled. No way to detect that on the server.
    • The client is a spider or does not understand JavaScript for other reasons per-se.
  2. The javascript is loaded from the CDN, which might be blocked. Or the clients connection might be unreliable.

  3. Anyway, the markdown-source is pre-cooked when the revision is saved, thus there is no saving anyway.
    You can observe that when a linked question on some SE site gets renamed or deleted afterwards.

3
  • Thank you for your answer. I don't understand point 3, can you elaborate? What do you mean by pre-cooked and no saving ?
    – Basj
    Mar 24, 2015 at 16:52
  • @Basj: The server translates the markdown to HTML only when the markdown is saved. Thus, pre-cooked. That's also when it looks up other pages on SE to render links better than as raw URLs. Mar 24, 2015 at 16:54
  • 7
    @Basj The rendered version of the post is permanently cached until the post gets edited. The server doesn't run the post through the Markdown parser every time the page loads.
    – animuson StaffMod
    Mar 24, 2015 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .