I have written some plugins for jQuery that are very often searched on Google. One of them is used for long-click event handler, presented in a "beautiful" way, for example:

$("a").longclick( function() { /* code */ }, 500 );

I want to share my work with everybody (for free). Is it OK to post a question on Stack Overflow and answer it myself? Or should I post somewhere else on the Stack Exchange Network?

You could create a tag and follow it. Then when you release it and people start using it, you can answer their questions for them. –  BeatAlex May 20 at 10:29
You can write a question and answer pair, but beware - though this is technically and officially OK, many people in the community take a dim view of such self promotion, whether for profit or not. –  Oded May 20 at 10:34
I am mostly worried about not being downvoted for something like this! –  Victor May 20 at 10:37
"I want to share my work with everybody (for free)". Are you not sharing your work already (if it's often searched on Google)? I'm just not sure whether you're talking about using SO as a code-snippet repository here, or whether you're talking about using SO to point to your work hosted elsewhere (e.g. GitHub). –  Bruno May 20 at 11:49
Also see How can Stack Overflow users be encouraged to use jQuery only when appropriate?. Questions and answers about a special plugin of a special library might not be very interesting and might result in only few views. Why not starting your own blog? –  Trilarion May 20 at 12:02
written some plugins for jQuery you should really add a tag as mentioned by BeatAlex. –  Mr_Green May 20 at 12:23
You should totally drop that and try... oh wait. –  Amal Murali May 20 at 13:15
I think it's okay to have a few "How I do make longclick (or X plugin) work with a custom function. Worst case scenario there's one of these for each plugin, but that's what would happen eventually anyway, this is just beating them to the punch –  TankorSmash May 21 at 12:43
Alternatively (or worst case scenario), you can always post a link in your profile description to your github profile, or even line-by-line links to individual repositories you wish to advertise. –  Paul Richter May 21 at 13:46
@Gracchus, will you upvote my code "for free"? :)) –  Victor May 21 at 17:11
Victor, quite simply .. search on SO and you will surely find someone asking about the issue at hand. Go right ahead and answer, or better, put it in as a comment, and include a link to your web page or whatever. By the way, what the hell is query?? –  Joe Blow May 22 at 10:08
Show HN (on Hacker News) should be a better option although I never read these posts.. –  cr0 May 22 at 10:09
SO does have a way to advertise open source projects. You could use that if it turns out your current idea isn't going to work out. –  Tyler May 25 at 13:10
@JoeBlow, and there are quite a bit of those questions already –  Basilevs May 27 at 2:31
Sounds like you need a blog. –  Ed B May 28 at 19:33

8 Answers 8

up vote 191 down vote accepted

Stack Overflow is not GitHub. I recommend that you not start turning it into a code-sharing service.

Then why are we encouraged to answer our own questions? I am just trying to understand what the founders said by that :-? –  Victor May 20 at 11:41
Your code is not an answer. Lack of your code is not a question. –  John Saunders May 20 at 11:42
@Victor: Suppose that you discover that JavaScript behaves weirdly with the absence of semi-colons at the end of a line (return\n"Hello, World"; and return "Hello World"; having different behavior), then asking the question and explaining what's going on to other people will help them. –  Matthieu M. May 20 at 11:46
If you make a fair question SO encourages you to keep searching for the answer, not just waiting for others to find the solution. If finally you found a valid answer out of SO, you should add it to your question instead saying "Nevemind, I solved it by my own" and removing it –  Pablo May 20 at 11:46
One of the other problems with publishing code on SO instead of GitHub (or other) is the licence. The CC licences aren't always the most appropriate for software. (If you do publish code on GitHub and have never done this before, please do remember to put a licence, otherwise we won't be able to use it.) –  Bruno May 20 at 11:58
@PabloLozano Closing it as a duplicate is a lot better. –  R. Martinho Fernandes May 20 at 12:25
@JohnSaunders is spot on. Thanks for the thought, though, OP. –  Lightness Races in Orbit May 20 at 12:33
@R.MartinhoFernandes I'm talking about keep investigating and trying to solve an issue without SO, not looking for a similar question in SO –  Pablo May 20 at 13:01
@Pablo then you should not remove anything but instead post the correct answer. Withholding knowledge doesn't help. –  R. Martinho Fernandes May 20 at 13:02
@JohnSaunders, I have just seen your comment! My code in this question is not meant for being the answer. The answer would be the complete code of the plugin with some explanation on it. –  Victor May 20 at 14:10
@R.MartinhoFernandes Mmmh, I know my English is as good as I'd like, but that's exactly what I meant. –  Pablo May 20 at 15:48
@Pablo Oh. I understand now! Your first comment makes sense if I add "of" after "instead". Sorry for the confusion. –  R. Martinho Fernandes May 20 at 15:56
John dude .. "why all the anger?" "Stack Overflow is not GitHub." OK - who says that? You? The founders of this business? Is it a "general opinion" or what, buddy? What's with the “Answer your own question – share your knowledge, Q&A-style”. I see everywhere? (is that "different"?) The only thing we know for certain about SO is: SO is a business like Pfizer or Google started by some guys to make cash money so that they can pay for diapers and bread. When you "recommend" that he doesn't use it as code sharing .. that's a harsh way to phrase "it would be a shame if...". You know? –  Joe Blow May 22 at 10:12
@JoeBlow Try not to confuse brevity with snark - I'm sure John didn't intend it. –  Tim Post May 22 at 11:55
"IMO, the founders of SE wanted to hijack the brain of all programmers and other field experts around the world and make a super clean encyclopaedia out of it". That's not even close. The founders of SE wanted to make money to eat - not complicated. it would be like saying "the founders of amazon wanted to help move books around the world!!" of course, the founders of amazon and stackoverflow wanted to: make money. To feed their children, buy diapers etc. –  Joe Blow May 27 at 6:47

We support answering your own questions, it's built right into the user interface. It's designed for those moments when you have this sort of epiphany, pull something together and want to make sure the next person finding themselves in that particular variety of quicksand is able to make use of your sage advice.

When you get into wanting to share a plugin, or entire library, it's better to just get it exposure using any of the code forges, and you can offer your plugin as a solution to questions where it would be appropriate. Just give thorough answers:

  • This is mine, I wrote it
  • Here is a code sample that encapsulates the example you provided
  • Here's further directions you could go with it, if you wanted
  • Here's (any applicable) shortcomings

I'm sure you'll find a few opportunities to do this, but make sure you answer other questions too - or folks might think you're being a bit spammy, even if it's open source (you do stand to gain contributors, but that's digressing).

I wouldn't out and out use the site as a platform to announce it, though - while I'm certain that many would appreciate it, an equal number wouldn't appreciate how you went about it, and would probably react negatively.

Folks have relaxed a bit when it comes to the use of the feature, but I fear this might be pushing it a tad bit far.

Nicely put. You've explained the general vibe of what is likely to happen and so on, and how that may or may not be changing over time. –  Joe Blow May 22 at 10:14

Answering questions to promote your own libraries (unless done in moderation and with the answer being useful without reference to an external resource) is likely to cause people to consider you a spammer. Creating questions that you can answer with such a promotion, more so.

Few times the same person who write answers has a 2nd account to write questions. You can easily see that by looking if answers are always to questions of the same person. Unluckily I saw that few times, and is likely that the answer from someone else will not be accepted. –  DarioOO May 23 at 12:38


Thank you!


Yes, definitely.

However, you need to care about asking the correct type of question for it:

  • [BAD] - What plugin should I use for …?

    SO is not a recommendation service. $("a").longclick( function() { /* code */ }, 500 ); would not be an acceptable answer.

  • [BAD] - What does a plugin to … look like?

    As @JohnSaunders has very nicely put it, SO is not a code hoster. Don't paste the source of your plugin in an answer.

  • [GOOD] - How do I …?

    You want to share your knowledge, not your plugin. Make an answer in which you outline the important techniques for …, and how to implement them. It's fine to cite relevant parts from your plugin's code for explanation purpose.

    In the end of the answer (or even in the first comment on it), you then can put Oh and btw, I've coded this into an easy-to-use jQuery plugin here with a link to your project's homepage.

I like this answer, it doesn't oversimplify the question. If a difficult problem is what led you to create a plugin, no reason not to share the journey with others who may run into the same thing. –  aw04 Oct 23 at 17:43

You could create a question at Software Recommendations SE (tagged with jquery) and answer it yourself, either including the full code (if it’s short) or linking to it. Make sure to disclose that it’s your software.

(You could also post a question with your code (or several questions about specific parts of your code, if it’s too long) at Code Review SE, asking for improvements.)

Note that any code you post on the SE network will be licensed under CC BY-SA 3.0. But you can, of course, license it under other licenses in addition, e.g., you could say that your code is also licensed under GPLv3 or that it’s in the public domain.


I think if you can formulate a good question, then give a good answer that includes your code, that is quite acceptable. However, if the question you give is "how do I do X beautifully", that is not acceptable. Make sure the question is something people actually ask, and represents a real problem.

Also, make sure the answer includes the code, don't link to your own website or blog. As long as the question is useful, and as long ad your answer is well written and includes your code, you should have no problems.

Once framed as a question, it may turn out that it's been already asked. Checking for that should also be part of the process. –  Daniel Vérité May 21 at 15:00
Make sure the question is something people actually ask, and represents a real problem. Wow, is that hair splitting. People will up- and down- vote for a variety of reasons -- but self-promotion is one of those things that can get you down-voted into oblivion if it's too obvious. –  McGarnagle May 24 at 17:51

For what it's worth... my #3 most upvoted answer was a question-answer pair I wrote myself.

Ref: On Windows 7, how does Java JVM set "user.home" System property?

I spent far too long on this problem. When I found the solution after very tough Googling, I wanted to share with others. StackOverflow did not have the answer. Admittedly, I felt awkward the first time. After I got votes on both sides (Q & A), I've done a few more.

I do this when an answer requires me to synthesize multiple, diverse sources: Google, official docs, source code, blogs, and StackOverflow.


As a newbie to this site I'd have to say I wouldn't care if the answer was self-answer/promotion as long as it solved a problem or gave me insight to a problem.


You must log in to answer this question.

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