286
votes
Accepted
I've been told to create a "runnable" example with "Stack Snippets". How do I do that?
Stack Snippets are an on-site tool similar to jsfiddle.net, codepen.io or plnkr.co. They're more limited than those tools, but they have the advantage of being on-site, so your code/markup is in your ...
Community wiki
243
votes
Accepted
How do I create a React Stack Snippet with JSX support?
Here's a step-by-step guide, first summary, then details with pictures. There are a couple of live demonstration snippets after the detailed instructions.
Summary:
Open the Stack Snippets editor by ...
Community wiki
144
votes
Feedback Requested: Code Editor and Stack Snippets
Usually I paste the code from my IDE where it's already correctly indented and formatted :).
In the rare cases where there aren't four leading spaces on the code lines (e.g. I've copied the code from ...

ChrisFMod
- 135k
70
votes
Accepted
Should questions with unnecessary Stack Snippets be edited?
Edit them
The snippet feature is of no use to posts where the code isn't meant to run. It only wastes space.
I usually also add a comment along the lines of:
"Please don't use Stack Snippets for ...
58
votes
Feedback Requested: Code Editor and Stack Snippets
As ChrisF♦ answered, as long as nothing changes when code is selected and I then press the button, I doubt there's anyone whose current workflow is interrupted by your change.
At least I doubt there's ...
47
votes
Stack-Snippets vs PasteBin, jsFiddle, and JSbin
Always prefer hosting the content on SO.
Thus, prefer having your pictures on SE's imgur-account, thus ensuring they will stay available as long as the SE network exists, instead of using any other ...
46
votes
Accepted
Some posts with snippets do not have a run button - Why?
After some digging, this is not a bug. The Stack Snippet is explicitly disabled when the post reaches a score of -3 or lower (i.e. when the post is greyed out), which is the case here.
Quoting Haney ...
45
votes
Should "Run Snippet" option have a reputation requirement? (To prevent... user stupidity and SE as an attack vector)
I think the problem is not in the snippets but with the owner of the router.
If your router can be hacked by a stack snippet, it can also be hacked by a malicious banner ad or by any website for ...
43
votes
Accepted
Is this 'Run code snippet' with payload an attempt to infect SO users' machines with a virus?
At the moment, Stack Snippets are, to the best knowledge of experts who've considered the problem (both SE employees and standard users like ourselves), completely sandboxed and pretty safe to run. ...
40
votes
Accepted
Stack Overflow reputation and profile link in email sign
You could use Flair.
Navigate to your profile -> "Edit Profile and Settings" -> Flair (under the Site Settings subheader). There you'll find an HTML snippet for a generated image with contains your ...
38
votes
Accepted
Unrunnable/useless Stack Snippets in Suggested Edits
You have four options. The first three are in order of most to least recommended:
You can flag one of the posts they've edited for moderator intervention and ask a moderator to intervene. I've done ...
38
votes
How to deal with a user reformatting snippet data to be in a single line
When the data is quite long, verbatim from the question (where the user left it expanded), not an important part of the answer, and the edits are to the answers that copied the extremely long sample ...
Ryan MMod
- 18.4k
35
votes
Feedback Requested: Code Editor and Stack Snippets
If the most common use case is not a runnable snippet (since it's only JavaScript, HTML, and CSS right now), what about an interface that goes immediately to a plain code editor, but has a big callout ...
35
votes
Accepted
Stack-Snippets vs PasteBin, jsFiddle, and JSbin
Where possible I usually try to include both a Stack-Snippet and a jsFiddle.
I still prefer working on people's problems in jsFiddle, not that jsFiddle is inherently better, I'm just used to the ...
34
votes
Accepted
Guideline on edits that only add/remove stack snippet
Edits adding a snippet
If the snippet demonstrates the issue the OP is asking about when you click Run code snippet, approve. If not, reject.
Edits removing a snippet
If the snippet demonstrates ...
34
votes
How can I add code to the head element when posting a code snippet?
If dynamically creating the <meta> tag isn't enough, there's a way to put the tag in directly, without JavaScript, through a hack. The text in the CodeMirror textareas will be inserted verbatim ...
34
votes
How do I demonstrate a preventDefault problem on a link in a Stack Snippet?
Although Stack Snippets prevent you navigating to a different document (or opening a new window), you can navigate within a document using a fragment identifier, which is all you need to demonstrate ...
32
votes
Accepted
Why does target="_blank" break links in snippets?
Stack Snippets are run inside a sandboxed iframe which only allows modals and scripts, and does not allow access to the top navigation. So anything but _self on a link will not work because it cannot ...
32
votes
Accepted
Why won't this snippet with async await work here on Stack Overflow snippet editor?
It's a Stack Snippets bug (but SE won't call it a bug, they call it a "feature request"), please see this question.
The problem is that the version of babel-standalone used by Stack Snippets ...
31
votes
Stack Snippets and document.write
even if it's clearly only for the purpose of demoing it on Stack Overflow?
My problem with willy-nilly tossing document.write into answers without disclaimer is that many new JavaScript developers ...
31
votes
Accepted
All my code is properly formatted, yet I am unable to post an answer due to unformatted code. Why?
In the first version of this question where you post your original markdown, you had indented code only one line down from your quoted text. When posting blocks of code there has to be a blank line ...
28
votes
Would it be feasible to add a regex snippet tool?
Very often answers linking to one of the popular online tools are the bad answers ignoring the specificity of the question.
There are too many differences between
flavors
implementations (and bugs)
...
27
votes
Accepted
Code snippets are not runnable on the Stack Overflow mobile website
I agree that this distinction should be removed.
Nowadays, mobile devices that can run JS are perfectly capable of running it properly.
The only issue SO would have with implementing this, would be ...
27
votes
Accepted
Stack Snippets that assign `var location` at the top scope redirect and produce “Server Error in '/' Application.”
It's due to the var location, which assigns to window.location and attempts to replace the page. But you assigned an object to location, resulting in a request to
https://stacksnippets.net/[object%...
26
votes
Should questions with unnecessary Stack Snippets be edited?
Whenever I see a stack snippet be used for plain code markup I edit it out. First I find the Run code snippet button annoying when it is not a stack snippet as there is nothing to run. Secondly, ...
25
votes
Accepted
Error while calling jQuery.show() in Stack Overflow snippet
The problem is that that jQuery's show calls showHide, which calls defaultDisplay.
That function attempts to determine the default display of the element, e.g. inline or block.
To do that, first it ...
25
votes
Sharing data between snippets, such as test inputs
Live shared data between Question and Answers: Don't do it
We should not have a shared snippet context between the question and answers. Doing so inherently sets up a dependency on the question for ...

MakyenMod
- 31.9k
24
votes
Feedback Requested: Code Editor and Stack Snippets
What about adding a dropdown to select the language too? While many questions can have it inferred from the tags, there are enough where it isn't that it would be useful to avoid having to hunt down ...
24
votes
Stack Snippets and document.write
In my opinion, document.write is fine, provided it's only used to output some variables in a snippet.
I'm not saying document.write itself is fine. document.write as an answer is (nearly) always bad.
...
24
votes
Accepted
Can we have an option to add more files in stack snippet like Plunker?
duplode alluded to it in the comments, but it's probably more concise to distill this point.
This would be extraordinarily prone to misuse.
Here's why:
We already have users who believe taking a ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
stack-snippets × 478bug × 194
feature-request × 159
discussion × 107
support × 82
status-completed × 48
design × 26
editor × 21
code-formatting × 17
edits × 16
suggested-edits × 11
code × 10
status-bydesign × 9
google-chrome × 9
user-experience × 8
jsfiddle × 8
answers × 7
asking-questions × 7
markdown × 7
status-review × 7
documentation × 6
user-interface × 6
help-center × 6
markdown-rendering × 6
tidy × 6