# Design Decision : Serverside or Client Side

**URL:** <https://talk.commonmark.org/t/design-decision-serverside-or-client-side/1178>\
**Category:** Application\
**Created:** [May 9, 2015, 4:23am UTC](https://talk.commonmark.org/t/design-decision-serverside-or-client-side/1178 "2015-05-09T04:23:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![v3ss0n](https://talk.commonmark.org/letter_avatar_proxy/v2/letter/v/b77776/32.png) [@v3ss0n](https://talk.commonmark.org/u/v3ss0n)\
**Post date:** [May 9, 2015, 4:23am UTC](https://talk.commonmark.org/t/design-decision-serverside-or-client-side/1178/1 "2015-05-09T04:23:10Z")

</div>

Planning to implement MarkDown Preview UI + Markdown Support for a chat application in development.

Web framework is python-tornado

MarkDown Lib i am looking is : remarkable (Faster than commonmark but follows commonmark specs)

For serverside Commonmark Ref implementation .

###Advantages :

- For clientside : we can do Syntax highlighting , live preview Markdown editor , like this : [Markdown Editor](http://jbt.github.io/markdown-editor/)

- For serverside - It gives security

###Things i need:

- clientside security implications of unsafe html ( attacker can just make a http post to bypass markdown preview editor and inject )
- Server Side performance of Markdown rendering or Markdown Verification
- Scalablity due to that i am implementing markdown enabled
- Syntax Highlighting (Commonmark dosen’t support it)

### What will be the optimum for both User Experience , Server performance and Security ?

- Client side Preview + Rendering with Server side verification (But server side verification will take about same performace as rendering? , Will it verify syntax highlighted results ? )
- Client Side (Just preview) with server side Rendering (Performance issue , need to plug syntax highlight (pygments) to commonmark.
- Client Side both rendering and Preview , nothing at server side (No Security at all, Highest performance , sytaxhighlight support) .

---

<div class="post-metadata">

**Author:** ![lu\_zero](https://talk.commonmark.org/user_avatar/talk.commonmark.org/lu_zero/32/557_2.png) [@lu\_zero](https://talk.commonmark.org/u/lu_zero)\
**Post date:** [May 9, 2015, 8:55pm UTC](https://talk.commonmark.org/t/design-decision-serverside-or-client-side/1178/2 "2015-05-09T20:55:58Z")

</div>

Client-side + Server-side rendering sounds the safest route.

You probably want to use [markdown-it](https://github.com/markdown-it/markdown-it) for the client side.

If you want to work on [CommonMark-py](https://github.com/rolandshoemaker/CommonMark-py) (or [my](https://github.com/lu-zero/CommonMark-py) slightly more featured version) would be great. Adding pygments to the default renderer should be quick.

---

<div class="post-metadata">

**Author:** ![v3ss0n](https://talk.commonmark.org/letter_avatar_proxy/v2/letter/v/b77776/32.png) [@v3ss0n](https://talk.commonmark.org/u/v3ss0n)\
**Post date:** [May 10, 2015, 4:47am UTC](https://talk.commonmark.org/t/design-decision-serverside-or-client-side/1178/3 "2015-05-10T04:47:24Z")

</div>

I am thinking about another route.

- On client side , markdown preview editor
- On POST , store **Raw** markdown in DB.
- On GET , Render the Stored markdown , stripping the unsafe HTML tags before Rendering.

I think it is Optimum for both Performance and Security.

This enable easy editing of documents too, without needing to convert back.

Any thoughts?

---

<div class="post-metadata">

**Author:** ![v3ss0n](https://talk.commonmark.org/letter_avatar_proxy/v2/letter/v/b77776/32.png) [@v3ss0n](https://talk.commonmark.org/u/v3ss0n)\
**Post date:** [May 10, 2015, 4:51am UTC](https://talk.commonmark.org/t/design-decision-serverside-or-client-side/1178/4 "2015-05-10T04:51:28Z")

</div>

I have a question , what is the difference between Reference Implementation of JGM’s Python CommonMark (which is updated frequently) vs CommonMark-py ?

---

<div class="post-metadata">

**Author:** ![lu\_zero](https://talk.commonmark.org/user_avatar/talk.commonmark.org/lu_zero/32/557_2.png) [@lu\_zero](https://talk.commonmark.org/u/lu_zero)\
**Post date:** [May 10, 2015, 10:50am UTC](https://talk.commonmark.org/t/design-decision-serverside-or-client-side/1178/5 "2015-05-10T10:50:38Z")

</div>

CommonMark-py is the js reference ported to python and yes, could enjoy more attention.

---

<div class="post-metadata">

**Author:** ![v3ss0n](https://talk.commonmark.org/letter_avatar_proxy/v2/letter/v/b77776/32.png) [@v3ss0n](https://talk.commonmark.org/u/v3ss0n)\
**Post date:** [May 11, 2015, 4:51am UTC](https://talk.commonmark.org/t/design-decision-serverside-or-client-side/1178/6 "2015-05-11T04:51:47Z")

</div>

whate are advantages vs the reference implementation : CommonMark .

---

<div class="post-metadata">

**Author:** ![lu\_zero](https://talk.commonmark.org/user_avatar/talk.commonmark.org/lu_zero/32/557_2.png) [@lu\_zero](https://talk.commonmark.org/u/lu_zero)\
**Post date:** [May 11, 2015, 10:57am UTC](https://talk.commonmark.org/t/design-decision-serverside-or-client-side/1178/7 "2015-05-11T10:57:27Z")

</div>

The python one is in python so you can render it using the ast directly instead of having the C version produce the json and from it deserialize to ast.
