Home > Software design >  Why Markdown is usually parsed in backend?
Why Markdown is usually parsed in backend?

Time:01-07

My impression is that Markdown can be parsed easily in Frontend, doing this also save server processing resources. But I have come across many web applications that parses Markdown in Backend instead, such as Gitlab, Github, FetLife.

What are the advantage for parsing Markdown in backend instead of Frontend?

CodePudding user response:

There are a number of reasons. Here is a partial list in no particular order:

  • Pages rarely consist only of the Markdown content. Other content, such as site navigation, sidebars, etc. all need to be rendered on the server anyway. Therefore, the entire page is rendered on the server.
  • Postprocessing often needs to be done on the rendered HTML. This often includes security based filters when hosting user provided content. Those filters are often kept secret to make it more difficult to find workarounds/loopholes for nefarious purposes.
  • The site might contain content which comes from sources other than Markdown (ReST, asciidoc, .org, texttile, etc.). Not all of those formats have a Javascript based parser available.
  • Any content rendered server side can be cached, eliminating the need to re-render the page for each request. Note, I'm talking about a caching system hosted on the server, not browser cache. Therefore, in some contexts a single cached page could be used for all users which would drastically reduce load on the server, much more so that utilizing client-side rendering.
  • As @Matthew mentions in a comment, "Doing things in the backend helps with indexability with search engines."

A large site like GitHub likely could list all of these reasons. In fact, GitHub actually documents there Markup processing at github/markup. Note that step 1 (of 5) involves converting from the source markup language to HTML. Steps 2 through 5 all happen separately afterward and are the same regardless of which Markup language is used.

  •  Tags:  
  • Related