View Single Post
Old 08-06-2025, 07:47 PM   #19
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,834
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Slevin#7 View Post
I agree that for most pure fiction stories EPUB2 is sufficient. But there are many other scopes where full EPUB3 functionality inlcluding JS would have great benefit
Yes, it is true that if the design is not very demanding, CSS2 may be sufficient in many cases, but epubs should still be epub3 (even if they only use CSS2). If the device accepts CSS3 and you're only providing CSS2, then the users are receiving a reading experience inferior to what they can expect.

That's why all epubs should be epub3 (since they can be opened by devices that only support epub2), containing the best code available for modern devices and fallback code for older ones. This way, users with modern e-readers will get the best out of them, and users with older e-readers will still get a satisfactory, but not optimal, reading experience.

And even novels and fiction books, without demanding design, can benefit from JavaScript. How? In many of my comments, I've affirmed the convenience of having the following property declared in the stylesheet:

Code:
body {
font-size: 1em;
}
With this, all the dimensions of the other elements set to "em" are referenced to that size defined in body. So if at any point, in body, instead of "font-size: 1em" we have "font-size: 0.8em", ALL the elements of the epub set to "em" will reduce their size (it would happen the other way around if the font-size increases). And where does JavaScript intervene? Well, it's very easy with JavaScript to determine the height and width of the viewport, know the available space (we'll know if the epub was opened on a large, medium, or small screen), and thus set an appropriate font size. This way, if the script detects a large screen, it does nothing, but if it detects a small screen, it overwrites the font-size value for body in the stylesheet to, for example, 0.8em. And with just this, all the values set to "em" in the epub are reduced. Of course, this don't negate the users' ability to set the font size they prefer, but it does provide a starting point, a point of comparison, to see how the epub looks with the optimal font size based on the detected screen size.

There are also other uses of JavaScript for fiction epubs that greatly improve the layout (for example, preventing text from overflowing in a block regardless of the user-defined font size; the text will always remain adjusted to the block size). And of course, adding hyphenation on devices that don't natively support this feature. This topic was recently discussed on the Sigil forum, when I asked Kevin if he could enable the Fetch API so that the Hyphenopoly script could also work in Sigil.

Last edited by RbnJrg; 08-06-2025 at 07:54 PM.
RbnJrg is offline   Reply With Quote