Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CRDOM203] [Html] HTML page must contain a doctype tag #103

Closed
Chmaqo opened this issue Apr 5, 2023 · 9 comments
Closed

[CRDOM203] [Html] HTML page must contain a doctype tag #103

Chmaqo opened this issue Apr 5, 2023 · 9 comments
Assignees
Labels
🗃️ rule rule improvment or rule development or bug 🏆 challenge2023 🏆 Work done during the ecoCode Challenge 2023 wontfix This will not be worked on

Comments

@Chmaqo
Copy link

Chmaqo commented Apr 5, 2023

Team 5R

@dedece35 dedece35 added 🗃️ rule rule improvment or rule development or bug php 🏆 challenge2023 🏆 Work done during the ecoCode Challenge 2023 labels Apr 5, 2023
@utarwyn
Copy link
Member

utarwyn commented Apr 7, 2023

Hello! I think that this rule is more related to HTML than PHP, no?
Maybe we could integrate it in the future HTML linter discussed in green-code-initiative/creedengo-javascript#4, if a warning is not already reported (because I think a document is not valid if DOCTYPE is not set, check doc here)

@MP-Aubay
Copy link
Contributor

MP-Aubay commented Apr 7, 2023

Does this issue is covered by this existing sonar rule : https://rules.sonarsource.com/html/RSPEC-1095 ?

@Silicoman
Copy link
Contributor

Yes, th'ats we have actually present in conference. Have to PR ecocode-common if i havent already did it. Will do next..

@Silicoman
Copy link
Contributor

@Silicoman
Copy link
Contributor

Silicoman commented Apr 11, 2023

@MP-Aubay , @mdubois81

I try to add a reference/validation to this doctype rule. The Kanban ticket is lacking info: only "CPU consumption"
https://github.com/orgs/green-code-initiative/projects/1/views/1?filterQuery=CRDOM203&pane=issue&itemId=22378285

Is it a fact?

I have checked differents infos... without being convinced.

Thanks for your help

Quirks mode: Quirks mode is a technique used by many web browsers for maintaining backward compatibility with web pages designed for old web browsers instead of strictly complying with W3C standards. In Quirks mode, the internet browser tries to interpret on ‘best-guess’, this associated with a general understanding of code that might be not well structured, non-standard, or ineffectively written implies your page is running without a type declaration
Reference: https://www.geeksforgeeks.org/difference-between-standards-mode-and-quirks-mode/


In addition, the lack of Doctype HTML, as well as the browser quirks mode, can lead to vulnerability flaws. The lack of this declaration, even in newer browsers, makes pages vulnerable to attacks such as RPO (Relative path Overwrite), which acts in the injection of style sheets.

Therefore, we should not state that the doctype is not mandatory. W3C itself guides its use. Therefore, the use of Doctype HTML is essential for any document. Therefore, its use is mandatory in view of good practices and also to guarantee the perfect functioning and security of the document.
reference : https://www.copahost.com/blog/html-doctype/


There is no performance gain to it as far as i know. However, using a DOCTYPE makes a browser layout the page in a standards-compliant (and a more consistent, but not totally) way across browsers. This is a "handsomeness" benefit rather than speed.
Since web browsers are implemented with special-purpose HTML parsers, rather than general-purpose DTD-based parsers, they don't use DTDs and will never access them even if a URL is provided. The DOCTYPE is retained in HTML5 as a "mostly useless, but required" header only to trigger "standards mode" in common browsers.
reference: ttps://stackoverflow.com/questions/9697117/is-a-webpage-loaded-rendered-faster-with-html-4-transitional-or-html-5-dtd

@dedece35 dedece35 changed the title CRDOM203[PHP] - HTML page must contain a doctype tag [CRDOM203] [Html] HTML page must contain a doctype tag Aug 25, 2023
@dedece35
Copy link
Member

dedece35 commented Sep 22, 2023

TO DISCUSS INSIDE CORE-TEAM : ok to merge associated PR ? (only add ecocode tag to existing SonarQube rule "Web:DoctypePresenceCheck")
@utarwyn : your point of view ?

@utarwyn
Copy link
Member

utarwyn commented Oct 6, 2023

This is an interesting idea, especially since this rule is essential in HTML5. So the starting point is to know if Quirks mode (which is activated when the doctype is not defined) is more resource intensive than standard mode.

Although I don't know exactly how browser rendering engines work, I am also unconvinced by the direct link with ecodesign. Experts seem to say that the difference in performance is negligible. The main objective of the DOCTYPE is to tell the browser to support all standard features and not stick with old ones (this is also why the rule on the SonarQube side is typed "user-experience"). BUT it is entirely possible that some of these standard features will increase page performance.

If we type the rule as "eco-design", we risk getting a lot of feedback asking us why it is typed that way. And without a concrete article explaining that Quirks mode is more resource-intensive (supporting proof), it seems complicated to argue..

I would be in favor of not typing it as "eco-design". For now.
Until someone proves that quirks mode really increases CPU consumption 👍

References:

@dedece35
Copy link
Member

dedece35 commented Oct 6, 2023

@utarwyn ok thank you for analysis
I think we can close this issue and wait for future. it's ok for you @utarwyn, @jhertout, @glalloue ?
(I moved the Kanban ticket to "hardly implementable")

@utarwyn
Copy link
Member

utarwyn commented Oct 16, 2023

After several tests, research, and given my comment #103 (comment) this rule doesn't seem to be eco-design as it stands. So I propose to close this ticket.

@utarwyn utarwyn closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗃️ rule rule improvment or rule development or bug 🏆 challenge2023 🏆 Work done during the ecoCode Challenge 2023 wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants