defer attribute is added to inline tags without src
-
Bug description:
When JavaScript deferral is enabled, the plugin adds the
deferattribute to all<script>tags, including inline scripts that do not have asrcattribute.Example output:
<script defer> window.someConfig = {...};</script>The
deferattribute should only be added to external scripts, i.e. scripts with asrcattribute:<script defer src="/path/to/script.js"></script>Expected behavior:
Only script tags with a
srcattribute should receivedefer.Actual behavior:
Inline script tags without
srcalso receivedefer.Why this is a problem:
deferis only meaningful for external scripts. Adding it to inline scripts is invalid/unnecessary HTML and can cause compatibility issues with validators, CSP-related tooling, or scripts that rely on exact tag processing.Suggested fix:
Before adding
defer, check that the script tag has a non-emptysrcattribute.
You must be logged in to reply to this topic.