A fix for slow ebooks

If suddenly you find your Kobo e-reader to be a lot slower than what you’re used to, the fault may lie with the particular e-book you’re reading. Check another book to compare. If you have one book that is particularly slow, this article will show you how to speed it up.

Recently, I noticed a significant drop in performance as I advanced in my latest read. Turning pages took a lot of time, and highlighting a word to find its translation was almost impossible.

I am using an ancient Kobo Glo, but it still works very well and I don’t feel like replacing it. After trying one of my other books, I became convinced that the problem was with this particular book, and that replacing my e-reader might not even fix the problem at all.

The problem

So I looked inside the epub file. Epub files are just compressed folders (.zip files), so you can use 7-zip to open them and look what they contain. Most e-books consist of a table of contents, one html file per chapter, image files and styling information (fonts and css).

In my case, I saw only two xhtml files, one for the cover and the other containing the rest of the book, all 355 pages and 43 chapters of it. I immediately suspected that the size of this file was causing the performance problem.

If only I could split this single file into one file per chapter, that would make this book just as fast as my other reads. But how can you edit an epub file?

The solution

Before I continue, I should clarify that you can only modify e-books that are not DRM protected. Fortunately, there are ways to remove DRM protection from e-books that you legally own. I won’t get into that here, just google it 🙂

A fantastic tool for creating and editing epub e-books is Sigil. One of the things it lets you do is to split an html file according to “markers” that you insert. So the proces is fairly simple:

  • Find the chapter boundaries in your html file.
  • Insert a “marker” before the start of each chapter.
  • Split the html file on the markers.

Let’s see how this is done. I’ll take my e-book as an example.

1. Find chapter boundaries

Open your e-book in Sigil and find the single, big html file in the Text folder. Open it and search for the chapter titles. (It helps to have your e-book open in your e-reader so that you can see what the chapter titles are).

Chapter titles can be <h1> elements but they can also be identified differently. In my case, they were simple <p> paragraphs with a specific class.

For example, the title of chapter 43 is quite simply the roman numeral XLIII.

<p class="Titulo" id="_idParaDest-44">XLIII</p>

In fact, all chapter titles have class “Titulo”, whereas regular paragraphs have a different class, e.g.:

<p class="Corpo_texto">O ribombar longínquo...</p>

2. Insert markers

The marker used by Sigil is a horizontal ruler with a specific class, i.e.:

<hr class="sigil_split_marker" />

In order to insert this before every chapter title, I used Sigil’s Find & Replace function, replacing

<p class="Titulo"

with

<hr class="sigil_split_marker" /><p class="Titulo"

Since my e-book was contained in a single xhtml file, I only needed to use the Replace All command once. If you have an e-book with several big html files, you may have to repeat this operation for every html file.

3. Split the HTML file

This is done using the “Split at Markers” command in the Edit menu. It’s that simple.

When I did this, Sigil even updated the Table of Contents automatically for me.

When you’re done, save your epub file (under a different name, just in case) and copy it to your e-reader. Enjoy!

Bonus: Make e-book images bigger

My e-book had another issue: it contains images from a manuscript that is essential to the story. But I couldn’t read them on my e-reader because they were too small.

In the HTML, I saw that (in my e-book), the images do not all have the same CSS class, but they always are contained in a paragraph that has the class “Figura”. For example:

<p class="Figura"><img alt="" class="_idGenObjectAttribute-2" src="image/Image2635.jpg"/></p>

The CSS file(s) for the e-book is located in the Styles folder in Sigil. In my e-book, it contains specific dimensions in pixels for each image. Which explains why the images are displayed as they are on my e-reader.

I could have changed the sizes for each and every one of the 41 illustrations, but it was a lot more efficient to globally scale all pictures. I chose to set the image width to 50% of the screen width.

In order to do this, I added the following rule to the e-book’s CSS file:

p.Figura img {
	width:50%;
	height:auto; 
}

The height:auto clause is required to ensure that the images retain their original aspect ratio.

What’s next?

Now that I enjoyed working with Sigil so much, I might just try to create my own e-book. You’ll be the first to know…

If this article was useful to you, please leave a comment below. And if it didn’t work, let me know as well!

Leave a Reply

Your email address will not be published. Required fields are marked *