On posts labeled HTML, JavaScript, or CSS, there should be a button labeled "Create Fiddle". The code in the posts may be sorted by the following rules. The first to match is considered correct. If none match, none are considered correct.

  • More < and > than { and } is HTML (minimum 4 brackets)
  • CSS if contains equal or greater number of colons than semicolons
  • JavaScript if
    • contains 1 or more semicolons
    • one or more "var" or "function", or three or more other JavaScript keywords
    • reason being other keywords are common in other languages


If tagged with a language supported by Ideone, other than JavaScript.


The user is shown a button, like the one on the right.

showing jsfiddle button mockup

Upon clicking it, StackOverflow makes an API call to host the code on JSFiddle.net. The URL is returned by posting a comment as the user that clicks Create Fiddle. The user is also redirected to the fiddle, via an _blank target on the link.

As with other automatic comments, the user may make changes to the comment, or remove it. If they feel it doesn't transfer well to a fiddle, the commend may be removed. If there's a glitch in the processing of the post; the user may fix the fiddle, click Update, and amend their comment to contain the new URL.

The same applies to Ideone, and their Clone feature.

Overall, this would improve answer speed. The worst case scenario, is that the user clicked the button, and it just didn't work. A few seconds lost on occasion is made up for by the massive collective time saved, and the benefit of more interactive solutions on StackOverflow.

  • 3
    If you have an answer, please post it. If you have a question meant to ask for clarification on a point raised on the question, then ask it. If you want to talk about unicorns, chat is over here. – George Stocker Mar 4 '13 at 15:17

I don't think this is a good idea.

Questions should really stand on their own without requiring those who wish to answer clicking on links which take them to other pages, let alone other sites.

For code in questions post the minimum code that demonstrates the problem. This doesn't have to be a complete working example, but enough that people can paste into an empty project (of whatever flavour) and see the problem reproduce. You never know, in reducing the code this way you might even solve your own problem.

Similarly code in answers should be enough to demonstrate the solution.

There's nothing to stop you posting a link to the complete solution as shortcut for people, but it should only ever be as a backup or reference for your question or answer.

  • 2
    I don't really see the need for this feature either, but it seems to me that the OP is not suggesting to move the content to the other site. Rather to (automatically) include a working link to a demonstration of the code already present in the question. In that sense it would only add to the content, though I think this might as well be done manually. – Bart Mar 4 '13 at 13:19
  • @Bart - Hmm, I see what you mean. However, my argument about keeping stuff on site still applies though. – ChrisF Mar 4 '13 at 13:22
  • sure, no argument there. – Bart Mar 4 '13 at 13:22
  • I often end up creating fiddles, and posting them in the comments. The questions and answers can stand alone, but a little help getting to the answers never hurts. The problem with creating a fiddle manually, is the code can be broken into pieces, and if HTML, CSS, and JavaScript are all present; each must be copied and pasted separately (JSFiddle's fault). It becomes tedious to do for each incoming question, but helps every potential answerer. As it says in the FAQ, we need to encourage experts to contribute their time. This why an hour gets 6 questions resolved instead of 5. – Brigand Mar 4 '13 at 13:23
  • 2
    @FakeRainBrigand Manual copying does not seem to take all that much effort. And I wonder how much development effort it takes to create a reliable system to automatically generate (especially) jsFiddles. I think we would see our fair amount of "I click the button, but the Fiddle doesn't even work" questions here. Not sure if it's worth the effort when it takes only a few seconds of copying and pasting. – Bart Mar 4 '13 at 13:29

I think this is a terrible idea as suggested, but I think the goal is a good one - making it easier for people to help answer questions by making live demos more accessible. Being able to quickly run some code is a huge benefit.

I really don't like the amount of dependency on external demo sites, jsfiddle in particular. Being able to access SO but have jsfiddle loading like molasses is very frustrating and happens to me all the time.

What I would love to see is an official demo site for Stack Overflow. I think it would solve a lot of problems, especially those concerning the longevity of the content. jsfiddle has no obligation to keep their site active or archive their content forever, although they do say SO makes up about 30% of their traffic, and people work around this all the time, posting questions and answers where the relevant content is hidden behind a jsfiddle link.

Until SO gets their own official code demo tools, anything else is just beating around the bush.

  • "StackFiddle" has been asked about before. Not sure why it hasn't been implemented yet (or why the-powers-that-be seem to have ignored it completely), though. – Shauna Mar 4 '13 at 15:45
  • +1 - for "jsfiddle loading like molasses is very frustrating". I actually like the OP's concept but we should be moving away from external dependencies. – Tim Medora Mar 4 '13 at 15:48
  • Ironically, the biggest fear against making the interface more friendly to jsFiddle, et al. is them going down either temporarily or permanently, yet zalun seems dedicated to keeping it and helping bridge the gap between SO and jsF, meaning it's not likely to go away (which in turn means the "workaround" to the absence of StackFiddle continues to work), leaving little incentive to bring it in house... – Shauna Mar 4 '13 at 15:49
  • I can see "StackFiddle" being a can of worms for a lot of reasons and understand why no one is eager to create it. Plus with the way people are around here, the feature creep/requests for StackFiddle will surely get out of hand. – user159834 Mar 4 '13 at 15:53
  • Which further strengthens the case for working with the existing tools in a way that helps make things more convenient (building in links to the runnable code), without sacrificing the "stand on their own" rule (provide said links as supplementary and still require the code blocks in the content). – Shauna Mar 4 '13 at 16:02

I think it's a good idea, provided the rule for "questions/answers must stand on their own" is still honored.

I've got a Chrome extension that I installed for other purposes, but it has the nice feature of turning SO's code blocks into ones with jsFiddle import capability. It's somewhat rough (doesn't pick up that disparate blocks should be for the same fiddle, and can't link to existing fiddles), but it does provide some enhancements to the current code blocking.

Here's what my interface looks like:

Fiddle-ehanced code blocks

Octopress has a good example for their code blocking with allowing for links to external places, which then show up in the title. This may require some kind of code fencing, or adding an additional HTML comment to work into the way SE's markdown processing works.

I don't think the "create fiddle" button is entirely necessary, but I do think something a little more friendly to code-running sites, in the absence of a Stack-hosted tool, would help with answering questions.

This does not mean that answers and questions should not stand on their own. However, the HTML/CSS/JS people already use jsFiddle extensively, and things like ideone have the potential to be beneficial to the users of other languages, especially when it comes to interface or runtime behaviors, where demo + code block provides more benefit than code block alone.

The idea here would be that the answers and questions would stand on their own, just as they do now, with the same standards as now, but with the added option of exporting or linking to a place that can run the code in question (saving people the time of setting up a local environment for something that would take 5 seconds to run in one of the web environments).

You must log in to answer this question.

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