Repository navigation
fix(rules): module scripts are not blocking in perf/inp-hints and perf/render-blocking (#424) - #428
Merged
Merged
Conversation
nc9
marked this pull request as ready for review
October 1, 2026 18:52
…f/render-blocking #424 Classify each <script src> the way the HTML Standard does: type=module defers by default (async with async), and nomodule or non-JavaScript types never run in a modern browser. perf/critical-request-chains uses the same helper so the three rules agree. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/module-scripts-not-blocking
branch
from
October 1, 2026 18:52
0925a36 to
4d7328e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #424.
perf/inp-hintsandperf/render-blockingcounted<script type="module" src>as blocking. Module scripts are deferred by spec, so a page full of them got "6 blocking scripts" and "7 render-blocking resources" for nothing.What changed
scriptLoading()inpackages/rules/src/performance/cwv.tsclassifies each<script src>the way the HTML Standard's "prepare the script element" steps do:type, emptytype, or a JavaScript MIME type;languageas the fallback):async,defer, or blockingtype="module"(case and ASCII whitespace insensitive): deferred, or async withasync;deferandnomoduledo nothingnomodule, or any othertype(text/plainconsent gates,text/partytown, data blocks): never run by a modern browser, so never blockingperf/inp-hintsandperf/render-blockingread it through the shared CWV hints.perf/critical-request-chainsuses the same helper instead of its own selector, so the three rules agree, and it no longer lists a<script src="">asJS: unknown.perf/inp-hintsis unchanged: a consent-gatedtext/plaintag usually runs once the banner is accepted.Result on the reporter's page
Run from source against the repro in #424:
inp-blocking-scriptspasses (0 blocking, 6 deferred),render-blockinglists only/style.css,inp-third-partystill reports the 6 tags.Tests
packages/rules/tests/script-loading.test.ts(new): the classification table, including whitespace, case,language, MIME parameters and emptysrc, plus the three rules on module, classic,nomoduleandtext/plainpages. 20 pass withcwv-reuse.test.ts.tsgo --noEmitinpackages/rules: clean.tangly check --strictindocs/: all checks passed.Thanks to @deniskern for the clear report and the repro page.