Performance warn by default
astro-doctor/no-blocking-script no-blocking-script
Disallow render-blocking <script src="..."> tags — add defer, async, or type="module".
Why
A <script src="..."> without defer, async, or type="module" blocks HTML parsing until the script downloads and executes. This delays the First Contentful Paint and Time to Interactive. Adding defer preserves execution order; async fires as soon as the script downloads; type="module" is always deferred.
Examples
✗ Incorrect
Render-blocking script tag
---
---
<html lang="en">
<head>
<script src="/analytics.js"></script>
</head>
</html> ✓ Correct
Non-blocking script with defer
---
---
<html lang="en">
<head>
<!-- defer — preserves execution order, non-blocking -->
<script src="/analytics.js" defer></script>
<!-- async — fires as soon as downloaded, order not guaranteed -->
<script src="/widget.js" async></script>
<!-- type="module" is always deferred -->
<script src="/app.js" type="module"></script>
</head>
</html> Configuration
Override the default severity in your ESLint config:
// eslint.config.js
import astroDoctorPlugin from '@santi020k/eslint-plugin-astro-doctor'
export default [
astroDoctorPlugin.configs.recommended,
{
rules: {
'astro-doctor/no-blocking-script': 'error', // or 'warn' or 'off'
},
},
]
Or in your doctor.config.ts:
export default {
rules: {
'astro-doctor/no-blocking-script': 'error',
},
}
All rules
-
astro-doctor/no-client-load-overuse -
astro-doctor/use-astro-image -
astro-doctor/require-image-dimensions -
astro-doctor/no-missing-alt -
astro-doctor/no-set-html -
astro-doctor/no-public-secret-env -
astro-doctor/prefer-class-list -
astro-doctor/no-blocking-script(this page) -
astro-doctor/no-unprocessed-script-surprises -
astro-doctor/no-missing-lang -
astro-doctor/require-island-fallback -
astro-doctor/no-process-env -
astro-doctor/prefer-content-collections