I would like to propose feature of enabling JavaScript in posts. This is site about Computer Science and some question naturally fits into interactive mode, or this simplifies enumerating possibilities.

As example I would like to show some questions:

Can a Red Black tree be constructed of only black nodes using RB insert only?

prove sufficient number of comparisons for the merge problem

How does this Turing machine accept $a^n b^n$?

Dynamically drawing trees, showing merge operations, or running simple TM emulator to show step by step what is happening would give another way to improve answers. It would be easier to understand concept and with low overhead it could turn answer into useful, interactive resource.

Any problems with this? I think that execute script on implicit request by user is must have starter. It could be enabled from some rep level and/or reviewed before accepting. I do not think that this would be overwhelming task, as this is first request and some questions are begging to be animated while others just can't.


It is security risk if: script is loaded and executed without interaction. If everybody without high reputation could use it, without revision and by enabling external sources. Everything could be managed and even more importantly it could be literally two embeded libraries executing only animations. Let me give example. User is given only access to Tree builder and Machine emulator. These libraries are internal, so there is no risk of external loading. User must have eg. 300 rep, and it is reviewed afterward to plug it in. Reviewing is not hard to this as there are limited capabilities and there are not many eager to write it.

BTW I today written RBT to make images. If user can only use script to add nodes to tree, what is the risk?

I know it is odd request and in pure form is out of question.

  • 1
    $\begingroup$ Enabling JS for user-provided code is a huge security risk. No, I don't want that. At all. $\endgroup$
    – Raphael Mod
    Aug 21 '15 at 16:24
  • $\begingroup$ @Raphael The JS would be sandboxed, of course. This exists on Stack Overflow and a couple other sites (see Jon's answer). $\endgroup$ Aug 21 '15 at 19:44
  • $\begingroup$ I'm told that the Snippets feature is incompatible with MathJax, so it's a non-starter for us. $\endgroup$ Jan 6 '16 at 21:47
  • $\begingroup$ Thank you @Gilles for update. It was kinda expected. Also usage was to show some animations like trees and make them permanent, but links I provided are all functional, and machines I wanted to show were discarded as HW, so no harm here. $\endgroup$
    – Evil
    Jan 6 '16 at 22:40

There is a Stack Snippets feature that we can turn on. However, as we told GIS:

[Snippets] are really only for JS/HTML/CSS code (a replacement for jsfiddle.net, basically). A good indicator of whether they'll be useful on a site is the number of answers with javascript in them, and especially posts linking to jsfiddle.

Not being directly the topic of the site, there isn't a lot of JavaScript and only one post links to JSFiddle. If I understand the request, it's about creating interactive examples embedded in posts. My suggestion would be to use JSFiddle for a while to see how useful/well-received that approach is. If it seems to be adopted by the community at large, we can think about turning on snippets here.

  • $\begingroup$ Ok seems fair enough ;) $\endgroup$
    – Evil
    Aug 21 '15 at 21:02

You must log in to answer this question.

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