Use of progressive enhancement techniques ensures content is available when scripting is not.
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.EPUB Content Documents 3.0
Progressive enhancement does not mean that you cannot script content, but that scripting must not be required. It is perfectly valid, for example, to remove content from the default rendering and replace it with an enhanced experience when scripting is available. It is likewise permitted to augment the default rendering with scripted interactivity. What you must avoid doing is scripting content such that without the scripting the primary narrative is not available in whole or part.
Validators alone cannot verify conformance to this criteria, so care must be taken when creating content to ensure that the key principles are observed. Notably:
- do not include content that can only be accessed (made visible) through scripted interaction.
- do not script-enable content based on a user’s preferences, location, language, or any other setting (without a default rendering).
- do not require scripting in order for the user to continue moving through the content (e.g., choose your own adventure books).
Whenever adding script, do so in a way that augments.
A common example of a scripted enhancement is the adding line numbering to code snippets. Many content
creators like to use ordered lists inside
pre tags to emulate line numbers, but an ordered
list can be distracting to someone using an assistive technology, and consufing and ugly to someone not
using a CSS-enabled user agent.
Instead of hard-coding the markup, a progressive enhancement technique would be to lay out your code samples so that they render as expected in the default preformatted view. You can then script, or grab a library, that can dynamically add the ordered list tagging to the element (which is what this site does). This approach ensures a baseline of readability in the most basic reading scenarios, while providing a richer visual view for those who have more advanced user agents.