Skip to content

perf/inp-hints and perf/render-blocking count type="module" scripts as blocking #424

Closed

Description

@deniskern

Summary

perf/inp-hints and perf/render-blocking count <script type="module" src=…> in <head> as blocking scripts. Module scripts are deferred by spec (HTML Standard: module scripts are fetched in parallel and evaluated after parsing, like defer), so they neither block rendering nor the parser.

perf/critical-request-chains already handles this correctly: it lists a classic local script but not a local module script.

Reproduce

Tested with v0.0.96 and v0.0.99 (linux-arm64), same result.

  1. Save as mod.html:
<!doctype html>
<html><head>
<title>module scripts</title>
<link rel="stylesheet" href="/style.css">
<script type="module" src="https://www.googletagmanager.com/gtm.js?id=GTM-XXXX"></script>
<script type="module" src="https://connect.facebook.net/en_US/fbevents.js"></script>
<script type="module" src="https://static.hotjar.com/c/hotjar-1.js"></script>
<script type="module" src="https://cdn.segment.com/analytics.js/v1/x/analytics.min.js"></script>
<script type="module" src="https://js.hs-scripts.com/1.js"></script>
<script type="module" src="https://widget.intercom.io/widget/x"></script>
</head><body><h1>Test</h1></body></html>
  1. Serve it: python3 -m http.server 8080
  2. Run: squirrel audit http://localhost:8080/mod.html --http -f json

Actual

  • perf/inp-hints: "6 blocking scripts"
  • perf/render-blocking: "7 render-blocking resources"

These are identical to the control page with classic <script src> tags.

Expected

Scripts with type="module" are not counted as blocking, the same as defer and async. That gives perf/inp-hints 0 blocking scripts and perf/render-blocking 1 resource (the stylesheet).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions