Back almost two years ago I posted some sample ColdFusion code that retrieved the followers for a Twitter user and then listed them by the number of followers they had. In other words, it told you who your most important followers were. (Well, "important" being measured by the number of followers a person has. One could argue that isn't the most important metric!)

I decided I'd rebuild it in HTML and JavaScript. This would let me run the script in a browser and check different accounts. Twitter's API (while it lasts) is pretty simple but doesn't support CORS. That means any time you use it via JavaScript you need to use JSON/P. That's not difficult either. I whipped up some code, wrote a custom sort on it, and hooked it up to a Handlebars.js template. All in all it was less then 40 lines of code:

Of course - while the code was easy - making it look hot was more work. Luckily, I was contacted by Amin Eftegarie. Amin graciously offered to do the design, and pushed me to actually put this code up on a domain and share it with the world.

You can run this code yourself at popularfollowers.raymondcamden.com. All the design is credit him. Trust me - my initial version was slightly uglier. ;)

Unfortunately, this solution is probably not as "tight" as I would like. I was never able to properly handle the error case for when a username didn't exist. I can handle errors in general, but I couldn't specifically notice/handle that case. Also - it's pretty easy to hit your personal API limit. I'll consider adding an OAuth type setup... but frankly... it works "good enough" for a toy and I'm satisfied with it as is. It also takes a little while to run. I've got 4.4K or so followers and it takes close to a minute to get them all and sort them out.

Oh - and I discovered that Melody Thomas Scott follows me. Awesome.