293
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
44
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
- 20.6k
35
votes
Accepted
Why won't this snippet with async await work here on Stack Overflow snippet editor?
Update: This is fixed as of Oct 3 2024, see the updates in this bug report (which SE called a "feature request").
The problem is that the version of babel-standalone used by Stack Snippets ...
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 ...
29
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 ...
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%...
23
votes
Accepted
How to provide additional code to comment an answer?
Or should I edit my question (risking that my question gets longer and longer)?
Do not edit and scope-creep your original question. If you have additional requirements exposed by the answer, ask a ...
23
votes
Accepted
How are Stack Snippets implemented?
The origin of the iframe is null because of the iframe's sandbox attribute (and the absence of the allow-same-origin clause).
Since the iframe's origin is null it can't access its .parent and thus can'...
23
votes
Accepted
Should I suggest edits to transform code blocks into Stack Snippets for HTML/CSS/JS questions?
I think I'll avoid suggesting adding them however unless there are other fixes I can make at the same time... Daniel Black
That's probably the safest thing to do. I would also add:
If it relies on ...
22
votes
How to make a working snippet with a library not available in HTTPS?
The best solution is to find an HTTPS based source for the file you desire to use.
Files in GitHub repositories are always available via HTTPS
jsDelivr (instructions for GitHub links)
Example:
GitHub ...

MakyenMod
- 33.6k
22
votes
Accepted
Stack Snippets Console can't output ES6 data types
I don't know that we can really expand those weak structures.
That said, a newer version of the console visualizer was mentioned back in January. That particular version replaced our JSON-flavored ...
20
votes
Accepted
How to use "code snippet" vs "code block"
Your assumption is correct, see this blog post for more information.
Not all users know how to format their code. If you come through such posts, simply edit them.
Removing the useless code snippet ...
20
votes
Accepted
Is it possible to have Python code snippets in Stack Overflow?
This is not feasible.
Stack snippets run entirely in the browser. You can't run Python in everyone's browser, not the CPython (main) implementation.
Python is a very, very rich ecosystem, with ...
20
votes
Accepted
Are Stack Snippets always safe to run?
No, not yet.
First, we need RFC 3514 to be adopted that would require evil doers on the internet to set the evil bit in IPv4 packets to signify they are evil.
RFC 3514 is not a technical requirement ...
19
votes
Accepted
How to ask a question that involves the loading of two HTML pages?
A minimal reproducible example does not need to be a Stack Snippet (Stack Snippets are just a good to have). If to reproduce a problem one needs to access multiple pages, then just post the MRE as ...
18
votes
Accepted
Removing Fiddle links
No, these links needs to be preserved. I'm not a lawyer but I do know that JSFiddle uses a different license for their code submission then SE does. Only the OP is allowed to copy over the code from a ...
18
votes
Is there an option to run my code snippet automatically when opening Stack Overflow questions?
No, there is no such option.
I also think such option would be open to abuse.
Some argue you will miss the juicy animation as it is already done once the snippet scrolls into view.
I prefer to click a ...
18
votes
Accepted
Add a warning about snippets being dangerous when they are run
So can Stack Snippets be confirmation-to-run when they have dangerous items (e.g. infinite loops, cookies, or infinite server requests)?
This is provably impossible. It would require solving the ...
Ryan MMod
- 20.6k
16
votes
Accepted
Is it possible to link directly to a full-screen code snippet?
Right now, no. There is not even a way to generate a link directly to the snippet either.
The results of a snipped are hosted inside an <iframe>, but there is no fixed url based on any ...
16
votes
Stack Snippets logging nested objects weirdly
You've found a bug (and a hack).
I have good news, though; they're both resolved in the latest version on github. I've replaced the old JSON-flavored object dumps with lazy tree expansion.
Here's a ...
16
votes
SO CSS animations overriding snippet CSS animations
It's the snippet console CSS, evidenced by disabling the console output:
<!-- begin snippet: js hide: false console: false babel: false -->
Demo:
@keyframes flash {
from { background-...
15
votes
Accepted
Can we have newer versions of third-party libraries in the Stack Snippets tool?
I've updated the versions for all listed libraries to reflect recent versions available on cdnjs as of November 16th 2018. This also involved switching to cdnjs as the host for jQuery and Angular.js, ...
15
votes
Accepted
Stack Overflow's snippet giving wrong results
It's because the variable name is status. It conflicts with the global window.status variable. When you rename status to e.g. foo, it works.
console.log(status); // <empty string>
var status ...
15
votes
Accepted
Should we edit questions'/answers' code into HTML/CSS/JS snippet, when it doesn't work?
The rule is:
Don't change the behavior of his code
If his code is missing a { or , don't add it as this may be the cause of the issue, thus the asked question. But if there is some local images and ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
stack-snippets × 503bug × 208
feature-request × 168
discussion × 110
support × 85
status-completed × 55
design × 26
editor × 21
code-formatting × 17
edits × 16
suggested-edits × 11
status-bydesign × 10
code × 10
google-chrome × 9
answers × 8
user-experience × 8
jsfiddle × 8
asking-questions × 7
markdown × 7
tidy × 7
documentation × 6
user-interface × 6
help-center × 6
markdown-rendering × 6
stacks-editor × 6