5 ms·
Show HN: Seen – Virtual list rendering with 1M+ notes
Edit: Thank you so much for taking a look at Seen! Yes, I know, it's really slow. And scrolling does not render notes instantly. And the title is a bit clickbait-y. I'll try my best to improve on it though. This is just a preview, the most basic version of Seen, and it's getting there. But, oh God, I almost got a heart attack when I opened up Vercel Analytics and saw ~1,500 page views, up from 10 or 12. Thank you again! It's such a weird experience showing something to the world for the first time as a 16-year-old and seeing so many people look at it.
Hello HN!
I've been working on creating a new note-taking app called Seen. Right now, it's really just a preview: virtual-list rendering ~1,000,000 notes in a masonry layout, while trying to minimize CPU and memory usage as much as possible.
Seen currently has:
- A client-side search feature
- Creating, updating, deleting the topmost note (locally; no changes are saved to any server)
- Automatic repacking of the masonry layout when the window width changes
- A lot of bugs, I'm sure
I reached a point where I thought I was ready to show the Seen to the world, and this is it. It's pretty basic, I know, but I'm really proud of it.
Seen was born out of an experiment to see just how fast things can become if you use the right techniques, and will (hopefully) achieve this dream sometime in the near future. My vision for Seen is to create something that can handle a lot of notes while using the least amount of resources. If you've got any suggestions or bugs, they're welcome in the comments!
A little about how Seen works: during the first visit, Seen caches note heights for the specific window width. Seen also caches the HTML output for the Markdown notes. It caches height by the key SHA256(title + note content), and the Markdown-to-HTML renders by the key SHA256(note content). It uses this cache every other time instead of recalculating, meaning that if most of the content remains unchanged, Seen can render things pretty fast. Caches are saved to IndexedDB.
When window width changes, the amount of text that can fit in a line also changes. So, Seen caches heights for specific window widths as well, putting the width in the key. Scrolling triggers an event handler that calculates the current viewport and finds & renders all notes that are visible (or partially visible) with a buffer of a 600px.
When a note is deleted or inserted, the entire layout is re-rendered. I plan on optimizing this to only re-render the specific column, which is what happens anyway when a note is updated. Updated notes create new caches (as they should).
- lelandfe 2y agoIf I tap and hold the scrollbar on my iPhone and scroll around, I’m looking at a blank page the whole time because the virtual list is waiting for me to finish.
- isoprophlex 2y agothey're virtually all there, though! :^)
- _bittere 2y agoOh yeah, that's a known bug. You're right, the scroll event handler is waiting for you to finish scrolling. I'm looking into it though!
- gkbrk 2y agoIs it fast by default? Every time I scroll up and down I'm looking at empty space while the notes load in. And it's not just initial network delay, even if I scroll over already loaded notes it takes time to display them. I think it would be a lot faster to do this with native HTML.
- deleted 2y ago[deleted]
- _bittere 2y agoNative HTML? As in actually rendering the 1M divs into the DOM?
- Etheryte 2y agoOut of curiosity, why SHA-256? I would wager using a non-cryptographic hash would be faster, no? In this context you don't need any of the crypto properties of it, so that could be an easy performance improvement for your cache. It seems currently the scroll struggles when you jump around, e.g. when you click to the bottom of the scroll bar area, the scroll will jump twice, first as you click and the second time as it renders. This is not a big issue if you continuously scroll, but is very noticeable if you use page down or click on the scroll bar. At least on my system, there is a noticeable delay between scrolling and the items being rendered on screen, that might be a related issue? Those notes aside, I could definitely see value for this in cases when you want to get a glance overview or similar of a large number of notes, it's a cool idea.