11

I came across a question today with some HTML and CSS, so I added it to a fiddle to see if I could work out the problem. I wasn't able to(properly) do so, so I commented a way I was able to work around the problem and added a fiddle for potential viewers that may be able to provide an actual solution. There is no jsfiddle included in the question, though it tends to be nice to have one provided along with the code. Because of this, the one I added in the comments contains the original code from the question.

So my question; Does something like a jsfiddle link belong in the comments? Or is it appropriate to suggest an edit to add the link to it when one isn't provided? It may even just be more appropriate to add a Stack Snippet, though I'm not really certain.

3
  • 8
    "more appropriate to add a Stack Snippet" - definitely, it then becomes a full part of the review history rather than a (potentially dying) link.
    – jonrsharpe
    Commented Jun 25, 2015 at 18:43
  • 2
    May as well use Stack Snippets for something good. Commented Jun 26, 2015 at 8:41
  • @NathanTuggy : but if they may be used for something good we will have to look at them before removing those damned snippets ;-) . Till now I have not seen one correct use case - but I must admit I'm not active in JS or HMTL tags ... Commented Jun 26, 2015 at 9:05

2 Answers 2

8

From what I've seen, it's OK to turn someone's code sample into a snippet as long as you don't make any changes to the code itself. No additions, no deletions. Any change is likely to get it flagged as an attempt to address the author of the post.

I don't think reviewers would like you adding a link to a fiddle that you control to the OP's question. For instance, the OP wouldn't be able to edit the fiddle later if it turns out they typed or copy/pasted part of their code incorrectly.

3
  • A valid point. I hadn't considered the fact that the OP wouldn't be able edit the fiddle later. They could save it as a new fiddle and update the link, but I think you're right that a reviewer wouldn't want to see that.
    – Jon
    Commented Jun 25, 2015 at 18:37
  • 1
    If doing so, make sure to add a descriptive comment on why you are editing and adding it or it may be rejected.
    – codeMagic
    Commented Jun 25, 2015 at 18:54
  • 6
    It's inappropriate for anyone to be able to change the linked content from out under the post. Stack snippets don't have that problem... Commented Jun 25, 2015 at 19:32
2

It is generally discouraged to change someone's code in a post. As a result, if you come up with a different version then what they have, it either belongs in an answer or as a comment.

If there is no change to the code, and you produce a jsfiddle with exactly the same code as shown and nothing else, then that content can be edited into the post and most users will view that as a productive edit.

Make sure that if you do place a fiddle of some sort in the post, that you still ensure that the original code remains in place, removing the code would not be a productive edit.

In addition, if fiddle can be easily converted to use the in-house Stack Snippet then go ahead and create one of those instead. It makes it easier on most users to simply run the snippet than to navigate to jsFiddle (or similar).

I have had users come by on some of my old answers and convert my working code only demos into snippets and I found it beneficial, and see no reason why it should not be done if it is a productive edit to the post which does not change the code.

1
  • 1
    "removing the code would not be a productive edit" - it really would be completely invalid edit as it turns proper SO post into one without code. Commented Jun 26, 2015 at 23:24

You must log in to answer this question.

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