gitwtfhub

wtf is epub.js?

futurepress/epub.js — explained in plain English

Analysis updated 2026-06-24

6,914JavaScriptAudience · developerComplexity · 3/5LicenseSetup · moderate

TL;DR

JavaScript library that renders ePub e-books directly in a web browser without any app or plugin, supporting both paginated and smooth-scroll display modes with a hooks system for annotations.

Mindmap

mindmap
  root((epub.js))
    What it does
      Renders ePub in browser
      No plugin needed
    Display modes
      Paginated
      Continuous scroll
    Features
      Hooks system
      Chapter navigation
      Annotations support
    Requirements
      JSZip dependency
      Modern browser

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Build a web-based e-book reader that lets users load and read ePub files directly in the browser without installing anything

REASON 2

Add annotation support to an ePub reader by hooking into Epub.js chapter-load events to inject custom markup before the reader sees the text

REASON 3

Implement a paginated or infinite-scroll reading experience for digital books inside a web or hybrid app

What's in the stack?

JavaScriptJSZip

How it stacks up

futurepress/epub.jsdoocs/technical-booksmatthew-andrews/isomorphic-fetch
Stars6,9146,9176,919
LanguageJavaScriptJavaScriptJavaScript
Setup difficultymoderateeasyeasy
Complexity3/51/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · moderate Time to first run · 30min

JSZip must be loaded before epub.js, JavaScript inside ePub files is disabled by default for security and must be explicitly enabled.

Use freely in any project including commercial ones with attribution, the BSD license is permissive.

Wtf does this do

Epub.js is a JavaScript library that lets you display ePub documents inside a web browser. ePub is a widely used format for digital books: it is essentially a bundle of HTML pages, images, and styling files packed together according to a standard schema. Epub.js reads that format and renders it as a readable experience directly on a web page, without requiring a dedicated app or browser plugin. The library provides methods for loading a book, rendering it into a specified area of the page, and controlling how the reader moves through the content. Two rendering modes are available: a default mode that shows one section of the book at a time, and a continuous mode that loads adjacent sections so the reader can scroll or swipe smoothly between pages. Page flow can be set to paginated, scrolled, or automatic based on the book's own settings. Epub.js includes a hooks system, which lets developers attach custom code to specific points in the rendering process. For example, a hook can run when a chapter is loaded into the page, allowing the developer to modify content or add annotations before the reader sees the text. The README notes that JavaScript embedded inside an ePub file is disabled by default, because scripts in a book file could pose a security risk. It can be enabled explicitly for trusted files by passing a configuration option, though the authors note this weakens the content sandbox. Using the library requires including JSZip (for handling compressed ePub archives) before epub.js. The built distribution file can be included directly from the repository's dist folder. Full API documentation is hosted at epubjs.org. The library is released under the BSD license.

Yoink these prompts

Prompt 1
Using epub.js, show me the minimal HTML and JavaScript to load an ePub file from a URL and render it paginated inside a div on a web page, including the JSZip dependency setup.
Prompt 2
I'm building a web e-reader with epub.js. How do I let users jump between chapters programmatically and save their last reading position to localStorage so it restores on reload?
Prompt 3
Show me how to use epub.js's hooks system to inject a custom annotation layer whenever a new chapter loads into the reader.
Prompt 4
I need to allow JavaScript inside ePub files in epub.js for a trusted document. What configuration option do I pass, and what security sandbox does it weaken?

Frequently asked questions

wtf is epub.js?

JavaScript library that renders ePub e-books directly in a web browser without any app or plugin, supporting both paginated and smooth-scroll display modes with a hooks system for annotations.

What language is epub.js written in?

Mainly JavaScript. The stack also includes JavaScript, JSZip.

What license does epub.js use?

Use freely in any project including commercial ones with attribution, the BSD license is permissive.

How hard is epub.js to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is epub.js for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.