Title: Reddit-like Collapsible Threads for Hacker News
Author: Alex Kirk
Published: February 16, 2010
Last modified: August 28, 2014

---

# Reddit-like Collapsible Threads for Hacker News

February 16, 2010

I enjoy consuming and participating at [Hacker News](http://news.ycombinator.com/)
by [Y Combinator](http://www.ycombinator.com/) resp. [Paul Graham](http://www.paulgraham.com/).

One thing that needs improvement is the reading comments there. At times it happens
that the **first comment develops into a huge thread**, and then the **second top-
level comment** (which might also be well worth reading) **disappears** somewhere
down into the page.

⌊Collapsible Threads at Hacker News through a bookmarklet⌉⌊Collapsible Threads at
Hacker News through a bookmarklet⌉[Reddit](http://reddit.com/) has combatted this
common problem by **making threads easily collapsible**. I think it is worth having
this also on Hacker News, so I implemented it and wrapped it into a bookmarklet 
so that you can use this functionality on-demand at Hacker News.

Drag this to your bookmarks bar: [collapsible threads](https://alex.kirk.at/2010/02/16/collapsible-threads-for-hacker-news/(function()%7Bvar%20s=document.createElement('script');s.type='text/javascript';s.src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js';document.documentElement.childNodes%5B0%5D.appendChild(s);s=document.createElement('script');s.type='text/javascript';s.src='https://alex.kirk.at/js/hackernews-collapsible-threads-v4.js';document.documentElement.childNodes%5B0%5D.appendChild(s);%7D)();?output_format=md)

As soon as it is available in your bookmarks bar, go to Hacker News and **click 
on it when viewing a comments page**. Next to each thread a symbol [+] will appear.
Click it to collapse the thread and it will change to a [-]. Click that to expand
the thread again.

I have licensed the source code under an MIT License. Click here to view the source
code of [hackernews-collapsible-threads.js](https://alex.kirk.at/js/hackernews-collapsible-threads.js).(
Actually for caching reasons the bookmarklet currently loads [hackernews-collapsible-threads_-v6_.js](https://alex.kirk.at/js/hackernews-collapsible-threads-v6.js)
which is actually just the same)

The Hacker News HTML source code seems quite fragile in the sense that the comments
section of a page can’t be identified in a really unique way (for example it does
not have an HTML id attribute), so it might break when the layout of the page changes.
This is why the bookmarklet is actually only a loader for the script on my server.
I have tuned the HTTP headers in a way that your browser should properly cache the
script so that the speed of my server should not affect the loading of the bookmarklet.

Enjoy :)

If you use Hackernews on another URL than news.ycombinator.com or hackerne.ws, use
this bookmarklet: [collapsible threads (no domain check)](https://alex.kirk.at/2010/02/16/collapsible-threads-for-hacker-news/(function()%7Bdomaincheck=false;var%20s=document.createElement('script');s.type='text/javascript';s.src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js';document.documentElement.childNodes%5B0%5D.appendChild(s);s=document.createElement('script');s.type='text/javascript';s.src='https://alex.kirk.at/js/hackernews-collapsible-threads-v3.js';document.documentElement.childNodes%5B0%5D.appendChild(s);%7D)();?output_format=md)

**Update March 18, 2011:** [Paul Biggar](http://www.paulbiggar.com/) has contributed
a [greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) script
that also works on Firefox 4. I have adapted it so that it also works (which basically
involved copying the jQuery script above mine) in Safari and Chrome (using [NinjaKit](http://d.hatena.ne.jp/os0x/20100612/1276330696)).

[Install Greasemonkey script](https://alex.kirk.at/js/hacker_news_comment_coll.user.js?output_format=md)

[Install Paul Biggar’s Greasemonkey script](https://alex.kirk.at/js/hacker_news_comment_coll-paul-biggar.user.js?output_format=md)

**Update November 22, 2011:** Eemeli Aro has sent me a little CSS tweak so that 
the lines don’t move around when collapsing. The code downloadable from above contains
his code. Thank you!

[Web](https://alex.kirk.at/category/web/)

Read this next

[Colorillo](https://alex.kirk.at/2009/10/22/colorillo/)

## 3 responses to “Reddit-like Collapsible Threads for Hacker News”

 1.  [uberVU – social comments](http://www.ubervu.com/conversations/alex.kirk.at/2010/02/16/collapsible-threads-for-hacker-news/)
 2.  [February 16, 2010](https://alex.kirk.at/2010/02/16/collapsible-threads-for-hacker-news/comment-page-1/#comment-83520)
 3.  **Social comments and analytics for this post…**
 4.  This post was mentioned on Twitter by akirk: New blog post: Reddit-like Collapsible
     Threads for Hacker News [http://alex.kirk.at/2010/02/16/collapsible-threads-for-hacker-news/](http://alex.kirk.at/2010/02/16/collapsible-threads-for-hacker-news/)…
 5.  [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2010%2F02%2F16%2Fcollapsible-threads-for-hacker-news%2F)
 6.  [Reddit-like Collapsible Threads for Hacker News Â» alexander kirk … · Staringfrog.com](http://staringfrog.com/sfwp/?p=2102)
 7.  [February 16, 2010](https://alex.kirk.at/2010/02/16/collapsible-threads-for-hacker-news/comment-page-1/#comment-83521)
 8.  […] Read more from the original source: Reddit-like Collapsible Threads for Hacker
     News Â» alexander kirk … […]
 9.  [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2010%2F02%2F16%2Fcollapsible-threads-for-hacker-news%2F)
 10. ![Alexander Kirk Avatar](https://alex.kirk.at/wp-content/uploads/sites/2/2025/
     06/cropped-2025.Alex-512x512-1-48x48.jpg)
 11. [Alexander Kirk](http://alex.kirk.at/)
 12. [February 21, 2010](https://alex.kirk.at/2010/02/16/collapsible-threads-for-hacker-news/comment-page-1/#comment-83531)
 13. Yes it’s working, just also tried it under Chrome (Mac, but should be the same).
 14. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2010%2F02%2F16%2Fcollapsible-threads-for-hacker-news%2F)

### Leave a Reply 󠀁[Cancel reply](https://alex.kirk.at/2010/02/16/collapsible-threads-for-hacker-news/?output_format=md#respond)󠁿

Only people in [my network](https://alex.kirk.at/friends/) can comment.

This site uses Akismet to reduce spam. [Learn how your comment data is processed.](https://akismet.com/privacy/)