Introducing epubjs
by Liza Daly
To celebrate TOC I’m announcing an early prototype of epubjs: a pure Javascript ePub reader. The entire application is only 11K (plus 53K for jQuery 1.3).
This is a pretty rough release, still very messy, but I’m hoping to evolve it into a lightweight reader that authors or publishers could add to their websites with minimal technical expertise.
Currently the reader works only in Firefox and requires that the ePub be expanded out in the top-level folder containing the JS code. (There are some issues related to browser security, and that it’s only been tested with this single ePub, and that I wrote a lot of this on the train ride down to New York).
You can extract the code directly out of the HTML file, or track it via Subversion:
svn checkout http://epub-tools.googlecode.com/svn/trunk/epubtools/epubjs epubjs

Comments
Are you aware of the Palm Pre? Its programming environment is HTML/CSS/JavaScript. Do you have any plans to port this over for that? Is it even possible?
I don’t know a thing about it, but one of the nice features of Javascript (and naturally, ePub) is that lots of platforms already speak it. I’d love to see this get used on mobile devices.
[...] — mikecane @ 3:16 pm The illustrious Kat Meyer retweeted a link that made my jaw drop: Introducing epubjs To celebrate TOC I’m announcing an early prototype of epubjs: a pure Javascript ePub reader. The [...]
Awesome ! Keep up the good work ! :)
Looks great typographically, but I miss seeing the page number you’re reading. Do you think that you could add the page number that’s displayed (something at the bottom of the page).
current_page/total_number_of_pages could be great.
Adrian, I agree. It’s actually a tricky problem, though, because most of this code handles making sure that none of the lines get truncated at the bottom. It does this by actually rendering the content to the browser, then checking which lines ended up below the bottom margin, and correcting it by pushing the overflow off to the next ‘page’.
So epubjs doesn’t really “know” how long a page is until it’s displayed. What I may try to do is provide a UI that gives you a relative sense of where you are in the chapter/book. With this algorithm it won’t be possible to show an exact page number, unfortunately.
I understand the need for pages on paper or eInk, but I always wonder why readers on the iPhone or the Web want me to turn pages instead of scrolling.
Jens,
Personally I don’t mind scrolling at all, but it seems that the majority of people prefer a paginated layout. If you took the pagination tricks out of epubjs you could probably write the whole thing in under 10 lines of Javascript.
[...] Initial code release post. [...]
[...] and JSEpub (screenshot) from August Lilleaas (@augustl). These two new readers join @liza’s epubjs, which will be a year old on Tuesday. An improved version of epubjs powers the ePub Zen Garden, [...]
[...] and JSEpub (screenshot) from August Lilleaas (@augustl). These two new readers join @liza’s epubjs, which will be a year old on Tuesday. An improved version of epubjs powers the ePub Zen Garden, [...]
ePub rawx! thank you for this.
[...] to the desires of ebook readers, help publishers understand how to get the best from ePub, and implement increasingly sophisticated ePub readers, we’ve gotten used to riding a fine line between [...]
Hello Liza,
I will start developing a website in which I’ll need the epub reader. Do you have more examples on how to use it? Did you develop more versions or not?
I want to add some functionalities like changing fonts or contrast for example. Can you help doing so?
Hi Rami,
I don’t plan on further updating epubjs myself. For more advanced JS epub readers look at either rePublish or Monocle.
Hey Liza, what’s the license on your code? It has no license at the top of the .js
Thanks, by the way, this is cool!
Sorry, the license is BSD following the rest of http://epub-tools.googlecode.com
[...] epubjs is a nice ePub reader written entirely in JavaScript, so if the Kindle and other non-ePub devices ever acquire a JS-enabled browser, or even just a local JS interpreter/engine, this will be another option for reading ePubs there. There is also a post at Ajaxian about some other JS-based ePub readers here. [...]