Skip to content

Script element document conformance requirements on attributes are incomplete and confusing #10070

Open
@domenic

Description

@domenic

What is the issue with the HTML Standard?

The script element is complicated. It has two "controlling" attributes, src="" and type="", and then 8 other attributes.

There are various attempts in the spec to disallow misusing the attributes. For example, saying that many different attributes cannot be used with import maps or data blocks. Or, saying that module scripts may specify the async attribute, but must not specify the defer attribute.

These attempts are not complete. For example, there are no restrictions on the blocking="" attribute, even though it only works in some cases. The only restriction on fetchpriority="" is on data blocks, but it should also be disallowed on import maps. Etc.

I'm not sure on the exact best way to address this. We could try adding more one-off rules, e.g. fixing the above two issues and any others I missed. But something more systematic would be ideal.

It would be pretty cool if we could end up with a table, kind of like the one for the input element: https://html.spec.whatwg.org/#the-input-element . However I'm not sure what the rows of the table would be. Maybe it would work to have them be {external classic script, inline classic script, external module script, inline classic script, import map, data block}?

Another approach would be to try to reorganize to be attribute-centric. E.g., when we describe the nomodule attribute, we describe exactly when it is allowed and disallowed. We don't spread that information out in multiple places. So in this version, you can read straight down a list of attributes, each getting one paragraph, with the first part of the paragraph describing the attribute and the second part describing its usage restrictions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions