Posted 12.01.2009

Importing a Twitter feed using jQuery

I’m going to cheat slightly.

I’m going to start jQuery week off with implementing a Twitter feed (instead of a Vimeo feed). Twitter is the easiest, so we can build up to the harder stuff. Hopefully after you read this post, you won’t feel slighted, either.


Obviously, you’ll need to go to and download the jQuery library.

Then, you’ll want to head over to Sea of Clouds and download their Twitter plugin. Their documentation is pretty straightforward. But, I’ll walk through the implementation process with you.

You’ll put the JavaScipt and CSS documents in their respective places (I keep all my javascript in a js folder and my CSS in a css folder).

In the head of your HTML document, you’ll want to link up all the files

<link href="jquery.tweet.css" media="all" rel="stylesheet" type="text/css"/>  
script src="js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.tweet.js" type="text/javascript" charset="utf-8"></script> 

Then, where you want the Twitter feed to appear, you’ll need to create some kind of hook. For example:

<div id="twitter_feed"></div

Next, you’ll initialize the Twitter plugin:

<script type='text/javascript'>
auto_join_text_default"I said,",
auto_join_text_ing"I were",
auto_join_text_reply"I replied to",
auto_join_text_url"I were checking out",
loading_text"loading tweets..."

The hook you created, is what you will use to call the .tweet() function.

The cool thing about this plugin is you can also perform a Twitter Search feed. When you initialize the plugin, you would use the following code instead:

loading_text"searching twitter..."

Now, everyone who mentioned in their Twitter would appear.

Lastly, you can pass an array into the username field. So, if you wanted more than one user’s tweets to appear, it would automatically sort them by time.


I told you this one was pretty easy. Next up? YouTube on Thursday.