-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Mark document.write()
as obsolete
#7977
Comments
Fixes #16852 See also whatwg/html#7977. This change adds a prominent warning to the top of the document.write() article, quoting the prominent warning from the HTML itself at https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document.write()
Fixes #16852 See also whatwg/html#7977. This change adds a prominent warning to the top of the document.write() article, quoting the prominent warning from the HTML itself at https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document.write()
Fixes #16852 See also whatwg/html#7977. This change adds a prominent warning to the top of the document.write() article, quoting the prominent warning from the HTML itself at https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document.write()
What are you suggesting specifically by saying "marked as an obsolete feature"? |
That the IDL
and relevant spec text are moved into the Obsolete features section (maybe a new subsection for dynamic markup insertion). |
What would the goal of such a move be? Note also that right now the "Obsolete features" section contains:
This would be the first instance of do-something methods in that section, that aren't related to a non-conforming HTML element. |
The goal is to more clearly be opinionated about the API having the same obsolete status as |
The user-centric goal is to drive down usage and nudge developers towards alternative patterns that don't block the HTML parser, which should make the web less slow for users. The long-term implementer-centric goal is to drive down usage over time until it's low enough that support can be removed completely. I don't expect this to happen anytime soon, if at all, though. |
It's not in the obsolete section.
I think MDN might be the best place for that? Or we could consider adding a "this feature is in the process of being removed from the web platform. (This is a long process that takes many years.)" box like we did for |
Yes it is: https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-all The spec for
I think we shouldn't say that it's in the process of being removed until it actually is plausible that it can be removed. It can be marked as obsolete even if it's never removed (like |
Speaking with my Open Web Docs member/MDN contributor hat on, I don’t see a problem with marking the MDN page with warnings and obsolete banners and what-all, and offer myself as tribute to add them if that’s judged to be a good idea by the group. |
I think the spec should be the source of truth for which APIs are obsolete or not obsolete, not MDN. |
Has usage in newly-authored content and the availability of reasonable alternatives with similar author ergonomics been surveyed recently? |
The The feature proposed in #7976 would also need to be shipped for developers to have an alternative for conditionally including module scripts that block rendering. I don't see a chromium use counter for document.write/ln. Am I missing it? If not, is there interest in adding one? |
Fixes #16852 See also whatwg/html#7977. This change adds a prominent warning to the top of the document.write() and document.writeln() articles, quoting the warning from the HTML itself at https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document.write()
Fixes #16852 See also whatwg/html#7977. This change adds a prominent warning to the top of the document.write() and document.writeln() articles, quoting the warning from the HTML itself at https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document.write()
This might be the wrong place to bring this up, but similar to not liking Appendix B in ECMAScript, I'm not a fan of HTML's Obsolete features. I'd prefer we figure out some consistent terminology across WHATWG standards (harmonize legacy/deprecated/obsolete; it seems historical already got removed) and settle for inline annotations. So features are still described as part of a larger whole, but it's clear when they're best not used. |
I’d suggest considering to harmonize on the term “discouraged”. For MDN we’ve had a similar need, and some rough consensus around moving to “discouraged” has emerged. If the HTML spec and MDN were to both move to using “discouraged”, that’d be some very nice harmony. |
Would obsolete elements also be "discouraged"? Currently the spec says obsolete elements and attributes must not be used (but doesn't seem to say that APIs in that section must not be used). |
For the HTML spec it seems if something’s already marked as obsolete, it’d be redundant to also mark it as “discouraged”. (For MDN, we no longer use “obsolete” at all, and what we’re considering is to replace “deprecated” with “discouraged”.) |
How about a WebIDL extended attribute
|
I think @domenic didn't like that last time it was suggested (by @saschanaz?) as it had no normative implications, but maybe "optionally call console.warn" suffices? (If we go with "discouraged" though the IDL attribute should match that naming.) |
"Discouraged" is used in HTML today for intentionally non-normative discouragement. We could change that, but I think if it means "must not use" (like obsolete elements), then "discouraged" doesn't seem like an appropriate term. But maybe such APIs should be "should not use" instead? 14 instances of "discouraged"
|
(Yeah, that was whatwg/webidl#910 and whatwg/webidl#929.) |
So we seem to be discussing a lot of related areas, all of which are worthwhile. Let me try to give a summary of the problem statement/state of things. I'll use the word "discouraged" as a general word, and "HTML-discouraged" to refer to the specific sense the HTML spec uses it per @zcorpan's comment #7977 (comment).
|
HTML also has "obsolete but conforming", which are should not use instead of must not use, and cause warnings in conformance checkers instead of errors. |
@jakearchibald noted in https://twitter.com/jaffathecake/status/1565289125468569601 that |
The
document.write()
API blocks the HTML parser (or rather,<script>
blocks the HTML parser because the script might usedocument.write()
) and can cause significant slowness for users (in particular when writing a<script src>
which also callsdocument.write()
, and again multiple levels deep). It's also responsible for significant implementation complexity to support (nested invocations of the parser, the need for speculative parsing...).The spec has this warning:
https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document.write()
Yet, this API is not marked as an obsolete feature. Why not?
MDN doesn't specifically discourage the use of
document.write()
: https://developer.mozilla.org/en-US/docs/Web/API/Document/writeI'm aware of the following issue that could be argued should block obsoleting
document.write()
:blocking=render
for dynamicimport()
#7976Are there any other reasons?
(Note that I'm not suggesting that support should be removed. That would not be web-compatible.)
cc @whatwg/html-parser
The text was updated successfully, but these errors were encountered: