Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 157 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

This question already has an answer here:

I've seen responses using, where the code is broken up into html, css, javascript and the output.

Q: If I have a post that includes a lot of code, is is better to post it to an outside source, or simply paste it into my question in a code block?

share|improve this question

marked as duplicate by gnat, Martijn Pieters, Richard Tingle, Hugo Dozois, hims056 Nov 7 '13 at 17:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 5 down vote accepted

Not sure how many people think like I do, but I don't leave SO to view code.

  1. I am hesitant to click on unknown links
  2. If the user is posting so much code that they need to do it off site then I don't feel like digging for a needle in a haysack.
  3. It requires me to look back and forth from the question and the code. It makes it easy if they are closer together.

My guess is that you will have fewer people attempt to answer the question if you do this.

share|improve this answer
It's a good point about the outside sites but there are a few that we know are trustworthy, like github or pastebin or jsfiddle so sticking to those is ok. Anyways the idea is that he should be trying to reduce the code to the minimum necessary to show the problem that's being faced. – jcolebrand Jan 5 '11 at 4:40
@drachenstern, I agree and Pekka had mentioned that in his answer, so I thought I would just focus on the answerer side. – jzd Jan 5 '11 at 12:19
I wanted to draw attention (shoulda gotten more sleep first) about sticking to well known sites so that we were comfortable clicking links. The second part was just for showing that I consider linking to code externally secondary to more explicit examples. – jcolebrand Jan 5 '11 at 15:12

The best thing to do is not to include lots of code in the first place. Try to isolate the very smallest piece that is necessary to illustrate the problem.

A JSFiddle is great for live demonstrations of stuff, but only posting a JSFiddle link is generally frowned upon.

If there is no way than to include the full code, I would post it on SO proper - SO's code formatting limits the height and adds scroll bars if it overflows.

share|improve this answer
Agreed. Always reduce to the minimum code that shows the problem, and always include the code in the question. But also including a link to a jsfiddle where people can see the problem in action makes my life easier as a potential answerer, and makes me more willing to spend some time on it. – Brad Mace Jan 5 '11 at 3:57
Pekka or @bemace - What should we do when we don't know how much of something needs to be shown? Is there a way to cause the scroll box to be shorter? I'm trying to post something to and I don't know how much of the information (a diff on two xml files) is necessary for potential answerers (and apparently "answerer" is a word). – sage Jan 7 '11 at 23:02
@sage hmm, hard to tell without seeing the question in question... If in doubt, you can always show everything and reduce the amount as things progress. – Pëkka Jan 7 '11 at 23:16
I decided this merits discussion and I posted to, where it seems more applicable: Is it... control the scrollbox height...?. – sage Jan 8 '11 at 1:01

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