Posted by & filed under epubjs, toc, tools.

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).

picture-63

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

Tags: epub javascript html jquery,

18 Responses to “Introducing epubjs”

  1. Mike Cane

    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?

  2. liza

    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.

  3. Adrian Fita

    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.

  4. liza

    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.

  5. jens

    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.

  6. liza

    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.

  7. Rami Henein

    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?

  8. Liza Daly

    Hi Rami,

    I don’t plan on further updating epubjs myself. For more advanced JS epub readers look at either rePublish or Monocle.

  9. Peter

    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!

Trackbacks/Pingbacks

  1.  ePub eBooks On The Palm Pre? « PrePoint
  2.  threepress: open source software for publishers » Blog Archive » epubjs updates: Safari support & pagination hints
  3.  Three JavaScript ePub Readers : Threepress Consulting blog
  4.  Ajaxian » Javascript ePub Readers
  5.  ePub and CSS: a reading system perspective : Threepress Consulting blog
  6.  Some neat e-reader tools « The World