BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Stack Overflow Adds Live JavaScript to Answers

Stack Overflow Adds Live JavaScript to Answers

This item in japanese

Developers have a new browser-based code editor to play with, but this time, it's embedded in another tool. Stack Overflow, the popular question and answer site for software developers, announced the release of a new tool that lets users run JavaScript, HTML, and CSS code right in the question page.

Dubbed "Stack Snippets", the new feature allows otherwise static questions and answers to include runnable code in-browser, similar to JSFiddle and Plunker. David Haney, the StackExchange developer behind the new feature, described it as "The best experience . . . where your question and answer(s) are complete and on the same page."

Stack Overflow has always allowed developers to post static code snippets and now, if a user chooses to embed runnable code, the code block will show a new button below:

The question and answer editors also have a new button

which opens up the new code editor

Before, to prove a piece of JavaScript code worked or not, users would often include static code in the answer and post a link to a working example. This became so common that some users stopped posting the static code and answered with only a link to the running version. This posed a problem if the link target broke resulting in an empty answer.

In 2012, StackExchange took steps to require answers with a link to jsfiddle.com or ideone.com include code. Stack Snippets tries to solve this external linking problem by eliminating the need to use an external service.

Geoff Goodman, the creator of Plunker, shared his thoughts on a Reddit thread:

Interesting solution. It certainly makes sense to allow code to be embeddable and runnable from SO. As the creator of Plunker (http://plnkr.co), I think that there will continue to be value in external services that provide a more complete UX and other value added bits like transpilation for things like less.

The only response from JSFiddle came in a tweet: "Well @stackexchange just cloned us :-)".

In a separate Reddit discussion, user davidNerdley said:

Saw it in the wild the other day. It is actually a lot nicer than I thought and makes reading the questions and solutions a lot more fluid. An already great resource just got even better.

But the response wasn't completely positive. Commenter JM on the announcement asked "Why waste all this time creating a substandard solution by re-inventing the wheel? Just integrate jsfiddle or jsbin."

Stack Snippets is now enabled on all code-related StackExchange sites and a sandbox is available to try out the new feature.

Rate this Article

Adoption
Style

BT