Skip to content

@briandoll /loud.on.twitter.html

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
<script src=""></script>
<script src="jquery.twitter.min.js"></script>
<style type="text/css">
body {background: #333; font-size: 64px; color: #999}
.twitter-posts {padding: 10px; list-style-type:none; border-bottom: 1px solid #000;}
.twitter-posts a {text-decoration:none; color: #FFF;}
<script type="text/javascript">
var parseQuerystring = function(){
var nvpair = {};
var qs ='?', '');
var pairs = qs.split('&');
$.each(pairs, function(i, v){
var pair = v.split('=');
nvpair[pair[0]] = pair[1];
return nvpair;
var qs = parseQuerystring();
var q = qs['q'] || '@github';
var c = qs['c'] || 2000;
$.twitter({limit: 1000, retweets: false, q: q}, function(tweets){
var musings = tweets.results;
var tweet_data = {};
$.each(musings, function(num, tweet) {
tweet_data[tweet.from_user] = tweet;
var authors = Object.keys(tweet_data);
var url = "";
$.getJSON(url + authors.join(), function(profiles){
$.each(profiles, function(count, author){
if (author.followers_count > c){
tweet = tweet_data[author.screen_name];
name =;
$('#loud-tweets').append($("<li>", {
"class": "twitter-posts",
html: name + " <a href='" + tweet.from_user + "' class='profile'>@" + tweet.from_user + "</a> (" + author.followers_count + ") says...<div class='tweet'><a href='" + tweet.from_user + "/status/" + tweet.id_str + "'>" + tweet.text + "</a></div>"}));
<div id="loud-tweets"></div>

I would like to understand how to do this with idiomatic JavaScript

This code works, but it's terrible JavaScript. I realized that when I started writing this code that I was attempting to write very procedural code. Sprinkle in some anonymous functions and callbacks and you quickly realize that the procedural code just isn't going to work.

I'd love to finally grasp modern idiomatic JavaScript. Fork and help me out?

(This is just a quick and silly example of something I was hacking together this week, but it's a good example of the problem I have in understanding how this type of code should be written.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.