Scripting in EPUB 3

Scripting in EPUB 3 should be considered an optional feature, and the main content of the book should be understandable without scripting. According to IDPF:

"when the document is rendered by a Reading System without scripting support or with scripting support disabled, the top-level document content must retain its integrity, remaining consumable by the User without any information loss or other significant deterioration."

Using a similar approach to handling embedded media, the following are recommendations on dealing with scripted content in EPUB 3:

  • Scripted content should not contain information that is critical to understanding the material.
  • If the scripted content is critical, a suitable alternative should be provided. For example, an alternative to a scripted quiz would be a an answer key.
  • Scripted content can also benefit from a synopsis so users can gain an understanding without having to run the script. This is particularly useful for reviewing material for study, or for situations where time constraints or the environment hinder the ability to interact with the script.
  • Interactables contained in <canvas> elements should have transcripts, answer keys / solutions, etc. Use aria-describedby to properly associate any canvas alternatives to the canvas itself.
  • Consider adding keyboard accessibility by ensuring all interactable components can be focused using the keyboard. This can be tested by using the tab key to navigate through the EPUB content and the embedded script.
  • The HTML that accompanies a script should be as standard compliant as possible and follow established best practices for HTML markup. This helps improve the likelihood that your script is understood by assistive technologies such as screen readers.
  • Embedded scripts should not contain invalid UTF-8 characters - some times these characters are generated by Javascript optimization schemes such as Uglify. The presence of these characters will cause the script to not appear properly in some reader systems. Example: A vertical Tab character (Unicode U+000B) will cause a script to not appear in iBooks, but will render fine in Readium. W3C's can help identify invalid UTF-8 characters.

Further reading