Don’t worry that this requirement means all the potential scripting fun is being taken out of ebooks, though. Games and puzzles and animations and quizzes and any other secondary content you can think of that requires scripting are all fair game for inclusion. But when it comes to including these there are two considerations to make, very similar to choosing when to describe images:
Does the scripted content you’re embedding include information that will be useful to the reader’s comprehension (demos, etc.), or is it included purely for pleasure (games)?
Can the content be made accessible in a usable way and can you provide a fallback alternative that provides the same or similar experience?
The answer to the first question will have some influence how you tackle the second. If the scripted content provides information that the reader would otherwise not be able to obtain from the prose, you should consider other alternative forms for making that information available, for example:
If you script an interactive demo using the canvas element, consider also providing a
transcript of the information for readers who may not be able to interact
with it.
If you’re including an interactive form that automatically evaluates the reader’s responses, also include access to an answer key.
If you’re adding a problem or puzzle to solve, also provide the solution so the reader can still learn the steps to its completion.
None of the above suggestions are intended to remove the responsibility to try and make the content accessible in the first place, though. Scripting of accessible forms, for example, should be a trivial task for developers familiar with WAI-ARIA (we’ll look at some practices in the coming section). But trivial or not, because scripting will not necessarily be available, it’s imperative that you provide other means for readers to obtain the full experience.
If the scripted content is purely for entertainment purposes, however, create a fallback commensurate with the value of that content to the overall ebook (if it absolutely cannot be made accessible natively). Like decorative images, a reader unable to interact with non-essential content is not going to be hugely interested in reading a five-page dissertation on each level of your game. A simple idea of what it does will usually suffice.