About This HTML Issue
The defer attribute is invalid on an inline <script>, because it only affects scripts that are loaded from an external file through the src attribute.
defer tells the browser to download an external script in parallel with parsing and run it after the document has finished parsing. An inline script has no external file to download, so there is nothing to defer and the browser runs it as soon as it is parsed. Because the attribute has no defined effect here, the validator flags it.
This usually happens when a template or a performance plugin adds defer to every <script> on the page, including the inline ones. async gets a similar error on inline scripts, except on inline module scripts (type="module"), where it is allowed.
Invalid example
<script defer>
console.log("Hello");
</script>
Valid example
Remove the defer attribute from the inline script:
<script>
console.log("Hello");
</script>
If you need the code to run after the document is parsed, move it into an external file and defer that instead:
<script src="app.js" defer></script>
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.