Script URL redirects: a 3xx in front of every script load
JavaScript files that answer with a 3xx before serving. squirrel reports every one with the pages that reference it.
Why a redirecting script costs
A script that answers 301 or 302 costs a full extra round trip before a byte of code moves. On a blocking script that delay is added to first paint, and it is paid on every visit that is not served from cache.
The causes are all historical: a CDN that changed its URL shape, a versioned path that now points at latest, a domain migration where the old host still answers with a redirect. The src attribute in the page is out of date.
What squirrel checks
The rule runs once per crawl over the script resources the crawl fetched. It emits one check named js-redirects:
- Skipped with the message
No JavaScript resources available for analysiswhen the crawl collected none. - Warning with the message
N JavaScript resource(s) redirect, one item per script carrying its URL, its status as the label, the pages that reference it, and its content type. The check’s value holds the first five as<path> (<status>)lines, with+N morewhen there are others. - Passing with the message
No JavaScript resources are redirecting.
A script counts when its recorded status is 300 to 399. That range includes 304 Not Modified, which is a cache revalidation rather than a redirect, so a conditional request answered from cache is reported alongside real redirects. The rule does not follow the redirect, so the destination is not shown; read the Location header once and paste the final URL into the page.
How to fix it
Point the tag at the URL the redirect resolves to:
<script src="https://cdn.example.com/v2/widget.js" defer></script>curl -sIL https://old.example.com/widget.js | grep -i location gives the destination. For a third-party script, check the vendor’s current documentation rather than following the chain, since they usually publish the URL they want you on.
The common false positive is a 304, which means the crawl’s conditional request was answered from cache and nothing is redirecting at all. Check the reported status before changing a URL. A redirect that exists to pin a version deliberately is also a trade the site may want to keep.
| Rule ID | perf/js-redirects |
| Category | Performance |
| Scope | Site-wide |
| Severity | warning |
| Weight | 4/10 |
Enable / disable
Disable this rule
[rules]
disable = ["perf/js-redirects"]Disable all Performance rules
[rules]
disable = ["perf/*"]Enable only this rule
[rules]
enable = ["perf/js-redirects"]
disable = ["*"]Related rules
- perf/critical-request-chains: the chain a redirect adds a link to.
- links/redirect-chains: the same problem on page URLs rather than assets.
- crawl/redirect-chain: redirect chains seen from the crawl side.
- perf/js-file-size: the scripts those URLs eventually serve.
Performance findings ship in every audit next to the SEO, security and agent experience rules. See Core Web Vitals for how an agent works through a report.
References
Check your site
Run squirrel audit https://example.com and open the Performance section of the report. Each redirecting script is listed with its status and the pages that load it. Local audits are free.