Skip to content
Enhanced eBooks in the browser.
Branch: master
Clone or download
Latest commit acecc25 Mar 8, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
documentation/md Fixed typo. Oct 29, 2018
examples Add linear prop for manifest imports Dec 21, 2018
libs Add metatags for annotations Jul 6, 2017
src Merge pull request #897 from mikkelvp/vendor-prefixes Mar 8, 2019
test Use alice epub for section#find() tests Jun 17, 2017
tools Updates to contents for Android, server update, jszip updated to 3.1.1 Aug 19, 2016
types Added Snap helper Nov 3, 2018
.eslintrc.js Added type declarations Aug 21, 2018
.jshintrc Added webpack build, karma test runner, travis config Oct 26, 2016
.watchmanconfig added polymer/url library Nov 15, 2016 changed npm run preprocess to npm run prepare (#922) Mar 8, 2019
bower.json Remove ePub.register, update Readme May 1, 2018
gulpfile.js Update gulp documentation Nov 6, 2017
license Add license file back, correct in package.json Oct 30, 2016
package-lock.json update url-polyfill Dec 6, 2018
package.json Version bump to 0.3.83 Dec 8, 2018

Epub.js v0.3

FuturePress Views

Epub.js is a JavaScript library for rendering ePub documents in the browser, across many devices.

Epub.js provides an interface for common ebook functions (such as rendering, persistence and pagination) without the need to develop a dedicated application or plugin. Importantly, it has an incredibly permissive Free BSD license.

Try it while reading Moby Dick



The EPUB standard is a widely used and easily convertible format. Many books are currently in this format, and it is convertible to many other formats (such as PDF, Mobi and iBooks).

An unzipped EPUB3 is a collection of HTML5 files, CSS, images and other media – just like any other website. However, it enforces a schema of book components, which allows us to render a book and its parts based on a controlled vocabulary.

More specifically, the EPUB schema standardizes the table of contents, provides a manifest that enables the caching of the entire book, and separates the storage of the content from how it’s displayed.

Getting Started

Get the minified code from the build folder:

<script src="../dist/epub.min.js"></script>

If using archived .epub files include JSZip:

<script src=""></script>

Set up a element to render to:

<div id="area"></div>

Create the new ePub, and then render it to that element:

  var book = ePub("url/to/book/package.opf");
  var rendition = book.renderTo("area", {width: 600, height: 400});
  var displayed = rendition.display();

Render Methods


book.renderTo("area", { method: "default", width: "100%", height: "100%" });

View example

The default manager only displays a single section at a time.


book.renderTo("area", { method: "continuous", width: "100%", height: "100%" });

View example

The continuous manager will display as many sections as need to fill the screen, and preload the next section offscreen. This enables seamless swiping / scrolling between pages on mobile and desktop, but is less performant than the default method.

Flow Overrides

Auto (Default)

book.renderTo("area", { flow: "auto", width: "900", height: "600" });

Flow will be based on the settings in the OPF, defaults to paginated.


book.renderTo("area", { flow: "paginated", width: "900", height: "600" });

View example

Scrolled: book.renderTo("area", { flow: "scrolled-doc" });

View example


API documentation is available at

A Markdown version is included in the repo at documentation/

Running Locally

install node.js

Then install the project dependences with npm

npm install

You can run the reader locally with the command

npm start


View All Examples


Test can be run by Karma from NPM

npm test

Building for Distribution

Builds are concatenated and minified using webpack and babel

To generate a new build run

npm run prepare

or to continuously build run

npm run watch


Similar to a plugins, Epub.js implements events that can be "hooked" into. Thus you can interact with and manipulate the contents of the book.

Examples of this functionality is loading videos from YouTube links before displaying a chapter's contents or implementing annotation.

Hooks require an event to register to and a can return a promise to block until they are finished.

Example hook:

rendition.hooks.content.register(function(contents, view) {

    var elements = contents.document.querySelectorAll('[video]');
    var items =;

      // do something with the video item


The parts of the rendering process that can be hooked into are below.

book.spine.hooks.serialize // Section is being converted to text
book.spine.hooks.content // Section has been loaded and parsed
rendition.hooks.render // Section is rendered to the screen
rendition.hooks.content // Section contents have been loaded
rendition.hooks.unloaded // Section contents are being unloaded


The reader has moved to its own repo at:

Additional Resources

Gitter Chat

Epub.js Developer Mailing List

IRC Server: Channel: #epub.js

Follow us on twitter: @Epubjs


EPUB is a registered trademark of the IDPF.

You can’t perform that action at this time.