Skip to content

Incorrect(?) error about type attribute value on script-element #1379

@melker

Description

@melker

When validating our site (https://liu.se/) I get the following error:

"A script element with a src attribute must not have a type attribute whose value is anything other than the empty string, a JavaScript MIME type, or module."
From line 34, column 1; to line 34, column 111
cript -->↩<script src="https://liu.se/mall20/script/site-liu.js" type="text/plain" data-cookiecategory="analytics" async></scri

We have set it up so that some script are first loaded when some cookies are approved by the visitor. The is a way to declare have some extra scripts that are not initially loaded. Some javascript is later loading it if later enabled. This technique is used by several cookie handling tools.

I think (from what I have read) that it should be perfectly fine to set the type attribute to something that is a valid Mime-type. "text/plain" should be fine.

According to:
https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
"The type attribute allows customization of the type of script represented:"
...
"Setting the attribute to any other value means that the script is a data block, which is not processed. None of the script attributes (except type itself) have any effect on data blocks. Authors must use a valid MIME type string that is not a JavaScript MIME type essence match to denote data blocks."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions