• Bug description:

    When JavaScript deferral is enabled, the plugin adds the defer attribute to all <script> tags, including inline scripts that do not have a src attribute.

    Example output:

    <script defer>  window.someConfig = {...};</script>

    The defer attribute should only be added to external scripts, i.e. scripts with a src attribute:

    <script defer src="/path/to/script.js"></script>

    Expected behavior:

    Only script tags with a src attribute should receive defer.

    Actual behavior:

    Inline script tags without src also receive defer.

    Why this is a problem:

    defer is 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-empty src attribute.

Viewing 1 replies (of 1 total)
  • Plugin Support miroslavtyurdiev

    (@miroslavtyurdiev)

    Hello @zid2000 ,

    Thank you for reporting this behavior. I tested the “Defer Render‑blocking JavaScript” feature thoroughly on a clean WordPress installation using the latest version of the plugin, including adding custom inline scripts to replicate your scenario.

    In my testing, inline <script> tags did not receive the defer attribute — only external scripts with a src attribute were modified. This is the expected behavior, and I was not able to reproduce the issue you described.

    Since this behavior does not occur in a clean environment, it’s likely that something specific to your setup is adding defer to inline scripts. This could be related to another optimization plugin or theme‑specific script handling.

    If you have a SiteGround account, I recommend opening a support ticket through your SiteGround Client Area. This will allow our support team to assist you more directly and efficiently.

    Best regards,
    Miroslav Tyurdiev

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.