magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

[W3C] Remove text/javascript from cookie script tag declaration

Open bhennesAdv opened this issue 6 months ago • 3 comments

Preconditions and environment

  • Magento version : 2.4.7-p6
  • Anything else that would help a developer reproduce the bug : Standard instance/All frontend pages

Affected template : https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Theme/view/frontend/templates/js/cookie_status.phtml

Steps to reproduce

If you load the homepage, or any other frontend page, you will have the following tag :

<script type="text/javascript">document.querySelector("#cookie-status").style.display = "none";</script>

According to W3C for some time now, adding text/javascript to script tag is unnecessary and will trigger a warning : The type attribute is unnecessary for JavaScript resources.

Expected result

Same tag should be present without the text/javascript type attribute

<script>document.querySelector("#cookie-status").style.display = "none";</script>

Actual result

See steps to reproduce

Additional information

This is not really an issue, only an improvement of generated code quality. If there is a reason why type is set on this tag and not elsewhere, please let me know

Release note

No response

Triage and priority

  • [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [x] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

bhennesAdv avatar Jun 11 '25 16:06 bhennesAdv

Hi @bhennesAdv. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.


Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

m2-assistant[bot] avatar Jun 11 '25 16:06 m2-assistant[bot]

PR was open without adding automatic test as it's not necessary for this kind of change.

Let me know if you need more information or if this change is not relevant.

Kind Regards, Baptiste

bhennesAdv avatar Jun 11 '25 16:06 bhennesAdv

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • [ ] 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • [ ] 5. Add label Issue: Confirmed once verification is complete.
  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Jun 11 '25 16:06 m2-assistant[bot]

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • [ ] 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • [ ] 5. Add label Issue: Confirmed once verification is complete.
  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Jun 26 '25 08:06 m2-assistant[bot]

Hello @bhennesAdv,

Thanks for the report and collaboration!

We have tried to find out the same in official W3c portal, but haven’t found the same. Can you please share the link which stats the same?

Thanks

engcom-Hotel avatar Jun 26 '25 08:06 engcom-Hotel

Hello @engcom-Hotel

Here is an example of a magento 2 website validator result : https://validator.w3.org/nu/?doc=https%3A%2F%2Fshop.landrover.co.uk%2Frange-rover%2Fthe-range-rover-collection

You can see a lot of warning with message : The type attribute is unnecessary for JavaScript resources

This is the kind of warning I'm trying to remove here. Here are some more information about it : https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type

Authors should omit the type attribute instead of redundantly setting it.

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type

Authors are encouraged to omit the attribute if the script refers to JavaScript code rather than specify a MIME type.

Kind Regards, Baptiste

bhennesAdv avatar Jun 26 '25 08:06 bhennesAdv

Thanks @bhennesAdv for providing the reference.

We are confirming this issue for further processing.

engcom-Hotel avatar Jul 02 '25 10:07 engcom-Hotel

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-15061 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Jul 02 '25 10:07 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Jul 02 '25 10:07 m2-assistant[bot]

Approved by Product Manager

tkacheva avatar Oct 15 '25 18:10 tkacheva