Epub.js: Rendering ebook formats in the browser without a plugin
Enhanced eBooks in the browser.
At a glance
- What is it?
- Epub.js is a JavaScript library that renders EPUB ebook files directly in web browsers without requiring reader software or plugins. It handles multiple display modes, customization through hooks, and sandboxes scripted content for security.
- Who is it for?
- Use Epub.js if you need to display EPUB books in a web application and can manage the browser compatibility testing yourself. Avoid it if you need active maintenance, regular security updates, or support for modern reading features like text-to-speech or high-performance scrolling on mobile.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Activity is slowing. The repository last received commits 6 months ago.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.
Editorial analysis
EPUB as a web-native format
EPUB is a standardized ebook format maintained by the IDPF. An unzipped EPUB3 file is a collection of HTML5 files, CSS stylesheets, images, and media, with a manifest that lists all contents and a table of contents file. This structure means EPUB is already a web format; there is no proprietary compression or binary encoding beyond the zip container.
Epub.js reads the manifest and table of contents, then renders sections of the book into a container element in the page. The library handles parsing the manifest, navigating the spine (the ordered list of chapters), and converting local file references into viewable chapters. Because EPUB is fundamentally HTML and CSS, the library's job is primarily to load, parse, and present the content that the format already contains. The format is convertible to PDF, Mobi, and iBooks, making it widely supported across reading platforms.
Display modes: paginated and continuous
Epub.js offers two core display modes. The default mode renders one section at a time, mimicking a physical book's pages. The continuous mode loads multiple sections and allows scrolling or swiping between them without page breaks, like a website. The continuous mode preloads the next section offscreen to enable smooth transitions on mobile and desktop.
Inside each mode, you can override the flow setting. The paginated flow displays content with discrete page breaks. The scrolled-doc flow renders content as a single scrollable document without page separators.
These modes trade off performance and feel. Default paginated gives the closest match to a printed book and is fastest for large books. Continuous scrolled feels more like reading web content but requires more memory and rendering overhead because the library must manage multiple sections in the DOM at once. The `method` parameter controls which display mode is used when calling `renderTo()`.
Getting started with Epub.js in the browser
Epub.js requires two script includes. If your EPUB file is archived (in .zip format), you must load JSZip first:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>Then load the epub.js library:
<script src="../dist/epub.min.js"></script>Create a container element where the book will render:
<div id="area"></div>Instantiate the book and display it:
<script>
var book = ePub("url/to/book/package.opf");
var rendition = book.renderTo("area", {width: 600, height: 400});
var displayed = rendition.display();
</script>This loads the EPUB file from the URL, creates a rendition (the display context), and renders the first chapter to the area div. The dimensions control the viewport. The library is available as the epubjs package on npm for use in Node-based projects.
Customization through hooks
Epub.js implements a hooks system that fires at specific points in the rendering pipeline. You register a function to a hook, and your code runs when that point is reached. Hooks can return promises to block rendering until they complete.
Available hooks include book.spine.hooks.serialize (when a section is converted to text), book.spine.hooks.content (after a section is loaded and parsed), rendition.hooks.render (when a section is rendered to screen), rendition.hooks.content (when section contents are loaded), and rendition.hooks.unloaded (when a section is being unloaded).
Hooks enable custom behavior like intercepting video elements and loading them from a CDN before the chapter displays, or implementing annotation layers. The README example shows hooking into rendition.hooks.content to find all elements with a video attribute and process them:
rendition.hooks.content.register(function(contents, view) {
var elements = contents.document.querySelectorAll('[video]');
var items = Array.prototype.slice.call(elements);
items.forEach(function(item){
// process the video item
});
});Security and scripted content
EPUB files can contain JavaScript embedded in HTML. By default, Epub.js disables all scripting in the EPUB content by sandboxing it inside an iframe. This prevents malicious scripts in untrusted EPUB files from accessing the host page.
If you need to allow a trusted EPUB to run interactive scripts, you can pass allowScriptedContent: true to the rendition settings. The README notes that this currently makes the sandbox insecure. For production use with untrusted content, keep scripting disabled and sanitize EPUB files server-side as well.
No longer actively maintained
The last push to the repository was on 2026-03-24, approximately six months before today. The most recent release was v0.3.88 on 2020-07-01. While the library still loads and renders EPUB files in modern browsers, it is not receiving bug fixes, security updates, or new features. The GitHub issues list contains 517 open issues, many of which have not received responses in several years. The package.json shows version 0.3.93, but release history shows the most recent stable release is much older.
For projects that depend on this library, consider whether your use case tolerates code that may contain unresolved vulnerabilities or compatibility issues with future browser versions.
EPUB reader and alternatives
The README points to a separate epubjs-reader repository that was the original web-based EPUB reader built on top of the library. That repository contains the user-facing UI. Epub.js itself is a rendering engine, not a complete application.
For commercial EPUB reading platforms, publishers and retailers use solutions like Kindle (Amazon's proprietary format), iBooks (Apple's ecosystem), or Calibre (an open-source desktop reader that handles many formats but does not run in the browser). For web-based EPUB reading with ongoing maintenance and support, consider whether a vendor solution meets your needs; building a custom reader on unmaintained JavaScript is operationally expensive.
Installation and building
For npm-based projects, epub.js is published as the epubjs package. Install with npm install epubjs and import from your code.
To build from source, install Node.js, run npm install to get dependencies, then npm run prepare to compile, build, minify, and generate legacy versions. Builds use webpack and babel. The test suite runs via Karma and can be executed with npm test. The build process generates multiple artifacts: a standard minified build, a legacy version for older browsers, and combined production versions.
Editorial conclusion
Use Epub.js if you need to display EPUB books in a web application and can manage the browser compatibility testing yourself. Avoid it if you need active maintenance, regular security updates, or support for modern reading features like text-to-speech or high-performance scrolling on mobile. Verify that the hooks system provides the customization you need and that your target browsers are listed in the test matrix.
Frequently asked questions
What is an EPUB file and how can I open it?
EPUB is a standardized ebook format that is fundamentally a zip archive containing HTML files, CSS, images, and metadata. Epub.js opens EPUB files by parsing the manifest and rendering chapters into a browser container. Other readers include Calibre (desktop), Kindle, iBooks, and native EPUB readers on Android and iOS.
What does EPUB stand for?
EPUB stands for Electronic Publication. The EPUB standard is maintained by the IDPF and defines a container format for ebooks based on HTML5, CSS, and web standards.
How do you use epub.js?
Epub.js loads an EPUB file via URL, parses its manifest and contents, and renders chapters into a container element you specify. You pass the EPUB URL and container ID to the ePub() function, then call renderTo() with display dimensions and optional settings for flow mode, render method, and hooks.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/futurepress-epub-js)