EPUBCheck RSC-034: script without JS media type
Updated:
EPUBCheck RSC-034 is an error message: “Scripts must have a JavaScript media type.” A script is declared with a media type that is not a JavaScript media type. EPUB 3.3 lists application/javascript, application/ecmascript and text/javascript as the core media types for scripts.
The official message
Scripts must have a JavaScript media type.
- Default severity
- Error. The EPUB breaks a rule of the specification and is invalid. Stores and Send to Kindle may reject it, and EPUBCheck exits with status 1.
- EPUBCheck version
- 5.4.0
Typical causes
- A manifest item for a .js file with a wrong media-type, such as text/plain or application/x-script.
- A script element whose type attribute names something other than JavaScript.
How to fix it
- Find the script named in the message.
- Set the media type to
text/javascriptin the manifest item and in the script element's type attribute (or remove type on script elements, which defaults to JavaScript). - Validate again.
When it's not this
An older JavaScript media type that still works only gives the usage message RSC-035.
Terms used here
Other RSC messages
RSC-033Relative URL strings must not have a query component, but found one in "…".RSC-035"…" is a legacy media type for JavaScript. Consider using 'text/javascript' instead.RSC-032Fallback must be provided for foreign resources, but found none for resource "…" of type "…".RSC-031Remote resource references should use HTTPS, but found "…".RSC-030File URLs are not allowed in EPUB, but found "…".RSC-029Data URL is not allowed in this context.
Sources
- EPUB 3.3, §3.2 Core media types · read
- EPUB 3.3, §6.3.2 Scripting · read
Message text and severity from EPUBCheck 5.4.0 (W3C, BSD-3-Clause). Explanation by EpubCC.