While we're discussing which optional features this SE needs, let's get the discussion about Stack Snippets out of the way.

Stack Snippets allow you to run JavaScript code right inside a post, which is great for small demos. I'm not sure how big the benefit would be here on CG.SE (due to the limitation to JavaScript), but I could imagine some great answers which contain a minimal working demo using WebGL.

The one drawback I can think of is an existing bug of the MathJax implementation which pops up quite commonly when using Stack Snippets, due to the ubiquity of $ in jQuery. This can definitely be worked around, but it's not ideal and definitely something to keep in mind.

Do we want Stack Snippets?

  • 1
    $\begingroup$ Hmm, if it would practically be an either or, then definitely MathJax first. $\endgroup$ Commented Aug 4, 2015 at 20:32
  • $\begingroup$ @ChristianRau Well, we can probably have both, if we're aware of the issues and are willing to live them. $\endgroup$ Commented Aug 4, 2015 at 20:33
  • 1
    $\begingroup$ @trichoplax why don't you make that an answer? ;) $\endgroup$ Commented Aug 14, 2015 at 9:17

3 Answers 3


We should have both now as there is a simple workaround

Briefly, we can choose between:

  • Just MathJax.
  • MathJax plus Stack Snippets that work perfectly well apart from jQuery which needs a minor workaround.

Note that MathJax works perfectly fine either way, so the choice can be summed up as:

  • No Stack Snippets at all.
  • Stack Snippets that work perfectly well apart from jQuery which needs a minor workaround.

The second option seems the obvious choice to me.

Here's a quick example of the kind of interactive 3D graphics that can be included in answers on sites for which Stack Snippets is activated

(Click "Run Code Snippet" at the bottom of that answer)

More detail

The problem is that using $ in a code snippet multiple times can lead to errors in the way the code is displayed, because MathJax also uses $. Note that this applies to code snippets in general - not just Stack Snippets, so not having Stack Snippets would not eliminate the problem.

As far as I can tell this mostly affects snippets that use jQuery, so it is perfectly possible to use pure JavaScript or other libraries.

Even for code using jQuery it is possible to work around the problem by simply using jQuery in place of $ ($ is just an alias for jQuery), which seems a fairly painless workaround.

Since this means it is already possible to use both MathJax and Stack Snippets, I see no reason to wait for things to be perfect. Once we have both, we can push for a fix, which I would guess would then happen faster for all sites affected, due to having more voices calling for it. In the meantime it has zero effect on MathJax, and a manageable effect on Stack Snippets.

There is also some discussion of it over on Programming Puzzles and Code Golf Meta.


Yes, but...

Live WebGL demos sound like a great opportunity for high-quality answers. But MathJax should have priority.

So, if we do want MathJax, we should wait with Stack Snippets until the bug mentioned in the question is fixed.

Edit: I personally no longer think this makes sense. Have a look at trichoplax's answer and feel free to change your vote.

  • 1
    $\begingroup$ I don't see any benefit of snippets unless webgl is supported. Does SE run those sandboxed? $\endgroup$ Commented Aug 4, 2015 at 20:48
  • $\begingroup$ @Qix WebGL has to be supported by your browser and Stack Snippets can embed any external JS (like WebGL Utils). They are sandboxed, but I'm not sure how that matters. It might be worth trying to write a short proof of concept in the Stack Snippets Sandbox. $\endgroup$ Commented Aug 4, 2015 at 20:53
  • $\begingroup$ @Qix as it happens there is already a webGL demo in the sandbox Martin mentioned. $\endgroup$ Commented Aug 5, 2015 at 17:57
  • 1
    $\begingroup$ @trichoplax well neat :D $\endgroup$ Commented Aug 5, 2015 at 20:13
  • 1
    $\begingroup$ In view of trichoplax's new answer, I'd -1 this one if I could. $\endgroup$ Commented Aug 14, 2015 at 11:37

Example questions to make the case that we have a need for Stack Snippets

This is a community wiki answer so anyone can edit in links to questions that would benefit from Stack Snippets to show runnable examples and live comparisons of different techniques.


You must log in to answer this question.

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