How to embed recent Tumblr posts

While searching around for a good way to embed recent tumblr posts onto my website, I came across a nice solution.

Louis Stowasser created a widget in Javascript that will easily display your recent tumblr posts after adding a few lines of code to your website or Tumblr blog. You are able to adjust the maximum amount of posts you want to show up and link to any blog you have. Here we have the code to embed your recent Tumblr posts:

Unminified (864 bytes):

<script type="text/javascript">
(function(blog, limit) {
limit = +limit || 10;

var scriptTags = document.getElementsByTagName('script');
var scriptNode = scriptTags[scriptTags.length - 1];
var recent = document.createElement("div");
recent.setAttribute("class", "widget");
recent.setAttribute("id", "TumblrRecentPosts");

var script = document.createElement("script");
script.src = "http://" + blog + "/api/read/json";
script.onload = function(data) {
    if(!tumblr_api_read) return;

    var response = tumblr_api_read.posts;
    var post;
    var len = Math.min(response.length, limit);
    var html = "<ul>";

    for(var i = 0; i < len; ++i) {
        post = response[i];
        html += "<li><a href='" + (post['url-with-slug'] || post.url) + "'>" + 
            post['regular-title'] + "</a></li>";

    recent.innerHTML = html;


})("", 30); //enter your settings here

Minified (573 bytes):

<script type="text/javascript">
(function(d,e){var  e=+e||10,
for(var a=tumblr_api_read.posts,c,d=Math.min(a.length,e),f="<ul>",g=0;
g<d;++g)c=a[g],f+="<li><a href='"+(c["url-with-slug"]||c.url)+"'>"+
c["regular-title"]+"</a></li>";b.innerHTML= f}};
("",30); //enter your settings here

How To Use:

  1. Choose one of the scripts above.
  2. Find where it says “//enter your settings here”.
  3. Change the URL to your blog; Adjust the number of posts you want to display (minimum 10)
  4. Paste the code in your HTML file or (if on your blog) go to your blogs Customization page
  5. Click the Edit HTML button.
  6. Paste the code wherever you want to display your recent Tumblr posts.