explaingit

futurepress/epub.js

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

TLDR

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
Click or tap to explore — scroll the page freely

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

Things people build with this

USE CASE 1

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

USE CASE 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

USE CASE 3

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

Tech stack

JavaScriptJSZip

Getting it running

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.

In plain English

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.

Copy-paste 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?
Open on GitHub → Explain another repo

← futurepress on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.