logoalt Hacker News

SamuraiLiontoday at 7:12 AM0 repliesview on HN

Thanks. The parsing cost is the entire one-time cost, the rest of the operation involves simply walking an array of words, a 900 page novel and a short story will perform the exact same. There is essentially zero cost in rendering a word at a time no matter the size of the book.

PDF is significantly the worst. We use pdf.js, and it has to page by page to retrieve the text layer, so a large book takes a little while and the tab feels 'busy' while doing so. EPUBs are considerably faster, it's mostly a case of unzipping and parsing xhtml.

The main thing that was the difference maker was separating storage into two IndexedDB stores, one for metadata, and one for the full text. When we open the library list we only read from the metadata store, not pulling the entire content of all books you own into memory. We only pull in the one you actually want to read.

The biggest edge case by far are scanned PDFs that have no text layer (there is no OCR, so nothing is returned) that are currently not failing audibly enough to make it clear.