BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Stack Overflow Adds Live JavaScript to Answers

| by David Iffland Follow 3 Followers on Oct 02, 2014. Estimated reading time: 2 minutes |

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 Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT