Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.


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 admin@quickmediasolutions.com


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

share|improve this question
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. –  Mark Henderson Jun 16 '10 at 2:25
@Farseeker: Ya, that's basically the idea :) –  Nathan Osman Jun 16 '10 at 2:27
I like it. Short, Sweet, Scooby Snack of an app. –  Sky Sanders Jun 16 '10 at 2:52
Please also vote for this app here so I can win the mini-contest. –  Nathan Osman Jun 16 '10 at 3:14
You can now link to stackad.js! –  Nathan Osman Jun 16 '10 at 3:35
Please let me know when you use it on your blog/site. I really appreciate feedback! –  Nathan Osman Jun 16 '10 at 3:40
As a complete side-note, consider supporting another open-source project by voting for this. –  Nathan Osman Jun 16 '10 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! –  Mark Henderson Jun 16 '10 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. –  Nathan Osman Jun 16 '10 at 5:35
@code: Do you mind if we hotlink Soapi.js and Soapi.Generated.js? –  Nathan Osman Jun 16 '10 at 5:39
I have created a minified version suitable for hotlinking. –  Nathan Osman Jun 16 '10 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. –  Sky Sanders Jun 16 '10 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. –  Nathan Osman Jun 16 '10 at 6:03
@code: In the meantime? Ah, never mind. I'll just host them on mine until you get something set up. –  Nathan Osman Jun 16 '10 at 6:04
I have minified the Soapi files and they are automatically included with the stackad.js source when necessary. –  Nathan Osman Jun 16 '10 at 6:31

1 Answer 1

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

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

You must log in to answer this question.

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