Skip to content

Inline module scripts can usefully have async #3

@tigt

Description

@tigt

ct/ct.css

Lines 187 to 203 in 1f0a063

/**
* Async and defer simply do not work on inline scripts. It won’t do any harm,
* but it’s useful to know about.
*/
head script:not([src])[async],
head script:not([src])[defer] {
border-style: var(--ct-is-problematic);
border-color: var(--ct-warn);
}
head script:not([src])[async]::before {
content: "The async attribute is redundant on inline scripts"
}
head script:not([src])[defer]::before {
content: "The defer attribute is redundant on inline scripts"
}

Async and defer simply do not work on inline scripts. It won’t do any harm, but it’s useful to know about.

This is true for classic scripts, but type=module inline scripts can usefully have async applied:

<script type=module>
  // I run like `defer`!
</script>

<script type=module async>
  // I run as soon as encountered but non-blocking!
</script>

defer is still useless, as it is redundant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions