Javascript support for ePub2 in iBooks

3 posts / 0 new
Last post

I am not sure but I have heard Apple's iBook is the only reader which is been supporting javascript and some sort of interactivity in ePub2 packages.
But, as per the IDPF specification, handling javascript in ePub2 books is invalid. Does that mean iBook would allow invalid ePub2 packages to render without validating it? A detailed explanation on this will be appreaciated.

Thanks,
Ravi Kumar

Handling scripting in EPUB 2 was never invalid, just not recommended. From section 2.3.7 of the OPS spec:

Reading Systems must not render the textual content of the script element, and should not execute the script itself. The content must be readable without execution of script elements.

"Should not" is not as strict as "must not", so Apple's supporting scripting is valid. Unless you're only expecting to distribute through iBookstore, it just doesn't make a lot of sense to include scripting in EPUB 2.

As far as validation goes, you should be able to side load anything you want into ibooks whether it validates or not, but if you want to distribute through the ibookstore the content has to validate (and Apple has its own constraints on top of what epubcheck validates, such as video format, file sizes, etc.).

Of course, loading invalid data into a reading system is likely to break its rendering, depending on the nature of the errors you haven't fixed, so it's probably not the best idea.

One more point - Apple iBooks was released in 2010, before EPUB 3 was developed, so in order to support interactivity they had no choice but to add JS support to an EPUB 2 environment. But since May of 2012 iBooks has officially suppored EPUB 3, so while the iBookstore may possibly still accept JS in EPUB 2 content there's really no good reason any longer to use it, and such content would be non-portable across other EPUB 2 Reading Systems.

Secondary menu