Wednesday, 2 June 2010

When all you have is a (jQuery) hammer, everything looks like a (jQuery) nail

It's no secret around these parts that I'm a big fan of the jQuery JavaScript library. It's certainly changed the way I write code, and has allowed me to do things that I wouldn't have thought possible before. But like most things, it's possible to rely on it a bit too much.

Recently, I wanted include a Twitter feed in a website. My immediate thought was "I bet there's a jQuery plug-in that does that".  And of course, there was one. In fact, there were quite a lot of them.

I tried a few, many of which had lots of impressive sounding features ("show all the tweets from user xyz that use the hashtag #foo and mention the word 'bar'!") . But I wasn't really happy with any of them, as they all felt a bit slow and bloated (probably due to the big list of features that I didn't actually need).

I then remembered that Twitter provides lots of ways to get this data via the Twitter API, as RSS, XML, JSON or whatever format you want. Once you've got that, it just takes a few lines of JavaScript (or you could just use the JavaScript that Twitter provides) to turn that into a feed that's embedded on your site.

Done, without a jQuery plug-in in sight.


Image by Cellular Immunity

No comments:

Post a Comment