Skip to content

Render-blocking a defer script or non-async module script #10068

Open

Description

@zcorpan

What is the issue with the HTML Standard?

See
mozilla/standards-positions#608 (comment)

My main concern is that it might be a bit too easy to block rendering on a defer (or module which is defer by default) script, and thus block until the timeout hits or until the full document is parsed. I'll file a spec issue.

In https://twitter.com/zcorpan/status/1744436513033630073 I wrote:

Should we make this not work, or warn in Lighthouse? With module scripts being defer by default it seems a bit too footgun-y IMO.

@noamr replied:

I think it works as intended… people have to explicitly mark those scripts render-blocking and doing so for an empty script would be very deliberate

me:

How about copypasta a third-party non-empty script with the blocking attribute?

@noamr:

As footguns go, this one is quite easy to spot (explicitly says render blocking) and more importantly to fix (add async). So IMO this is a matter of documentation rather than changing behavior.

For short documents, using render-blocking and defer together seems OK. So I'm not proposing that the spec should change to make blocking=render do nothing for defer or non-async module scripts. But maybe the spec should at least have a note or a warning about the implication of this combination, and developer tools / performance checks could have a warning at least when render-blocking has been active for a certain time.

Activity

  1. noamr commented on Jan 16, 2024

    @noamr
    Contributor

    Sounds good. In general I think the recommendation should be that blocking=render should be used together with async.

  2. added
    topic: script
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions