This page is due for an update but until then you can add StackAd to your site by adding:

<script type='text/javascript'

to the <head> section of your page and sticking the following <div> on the page where you want the ads to appear:

<div class='stackad' data-site='stackoverflow.com'></div>

...where data-site is the parent site of the Stack Exchange site whose ads you want to display.

Screenshot / Code Snippet

StackAd demo available here.


StackAd pulls the answers from this question that have 6 or more upvotes and displays a random ad in the box. The code is provided as a .js file you can embed in your pages. The instructions are here.


As is common with all of my open-source apps, I am going with the MIT license.


http://stackoverflow.quickmediasolutions.com/stackad/stackad.js <- This file can be hotlinked and has been minified to save bandwidth
http://stackoverflow.quickmediasolutions.com/stackad/stackad-source.js <- This is the source
http://stackoverflow.quickmediasolutions.com/stackad/test.html <- to see a demo
http://stackoverflow.quickmediasolutions.com/stackad/fancy.html <- to see an even better demo


The code should work with any JavaScript enabled browser.


I can be reached at [email protected]


The code is written in JavaScript and uses the Soapi.js wrapper for interfacing with the API.

  • Hey, that's a pretty unique use for the API! <s>But... what are you going to do when a new thread is created and the question number changes?</s> - nevermind, if you do a copy/paste style app then you can change your hotlinked JS file. Commented Jun 16, 2010 at 2:25
  • @Farseeker: Ya, that's basically the idea :) Commented Jun 16, 2010 at 2:27
  • 2
    I like it. Short, Sweet, Scooby Snack of an app. Commented Jun 16, 2010 at 2:52
  • Please also vote for this app here so I can win the mini-contest. Commented Jun 16, 2010 at 3:14
  • 1
    You can now link to stackad.js! Commented Jun 16, 2010 at 3:35
  • 1
    Please let me know when you use it on your blog/site. I really appreciate feedback! Commented Jun 16, 2010 at 3:40
  • As a complete side-note, consider supporting another open-source project by voting for this. Commented Jun 16, 2010 at 3:44
  • @George, just looking at stackad.js, a few suggestions: 1) Check for JQuery and include it's not there (hotlink to the Google Hosted version), 2) Check for SOAPI.js and include it automatically if it's not there. 3) The ID of "banner" is incredibly common. Maybe call it "so-oss-banner" or something? This way it's an all-in-one solution and is really just a copy/paste solution. Also, 4) for your own bandwidths sake, you might want to run it through a minifier. That copyright notice will cost you a lot of money if you're not careful Other than that, looking good! Commented Jun 16, 2010 at 5:27
  • @Farseeker: Ya, those pretty much mirror my todo list - I will fix those pretty quickly. #2 might be slightly more difficult though. Update: Fixed #3 already. Commented Jun 16, 2010 at 5:35
  • @code: Do you mind if we hotlink Soapi.js and Soapi.Generated.js? Commented Jun 16, 2010 at 5:39
  • I have created a minified version suitable for hotlinking. Commented Jun 16, 2010 at 5:45
  • well, the files will be in the same place but until the api goes gold and stops moving I can guarantee the functionality. This would be the issue with hotlinking. And I have yet to wire up minification to my build process yet. when I find myself with some time I will build in minification and output files with version numbers that can be linked. Commented Jun 16, 2010 at 5:57
  • @Farseeker: I implemented your idea - the script now searches for and detects if jQuery has been included and otherwise loads it from Google. Commented Jun 16, 2010 at 6:03
  • @code: In the meantime? Ah, never mind. I'll just host them on mine until you get something set up. Commented Jun 16, 2010 at 6:04
  • I have minified the Soapi files and they are automatically included with the stackad.js source when necessary. Commented Jun 16, 2010 at 6:31

1 Answer 1


Is there a way for this work for other, non-stackoverflow (think: Ask Ubuntu) community ads?

  • You know... I honestly never thought of that... I will investigate this and report my findings. Commented Nov 7, 2011 at 17:22
  • @GeorgeEdison shouldn't be too hard, it's already pulling it from a stackoverflow question...
    – jrg
    Commented Nov 7, 2011 at 17:34
  • 1
    It is, but some bugs were later discovered in the StackAd code that need to be fixed as well. Commented Nov 7, 2011 at 17:34
  • I totally forgot about this - but yeah - this has been implemented now. Commented Feb 21, 2012 at 1:59

You must log in to answer this question.

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